Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler assert on @naked function with inline assembly and pointer #1955

Open
Book-reader opened this issue Feb 11, 2025 · 5 comments
Open
Labels
Lower Priority This issue has lower priority for some reason
Milestone

Comments

@Book-reader
Copy link
Contributor

fn void main()
{
	char[8] foo = {255, 0, 0, 0, 0, 0, 0, 0};
	io::printn(to_ulong(&foo));
}

fn ulong to_ulong(char[8]* buf) @naked @noinline
{
	asm
	{
		movq $rax, [buf];
		ret;
	}
	unreachable();
}
⚠️ The compiler encountered an unexpected error: "Violated assert: decl->var.kind == VARDECL_GLOBAL || decl->var.kind == VARDECL_CONST".

- Function: llvm_get_ref(...)
- Source file: ../src/compiler/llvm_codegen.c:1283

🙏 Please consider taking the time to file an issue on GitHub, so that we can get it fixed:

https://github.com/c3lang/c3c/issues/new so that we can get it fixed.
@lerno lerno added the Lower Priority This issue has lower priority for some reason label Feb 12, 2025
@lerno
Copy link
Collaborator

lerno commented Feb 12, 2025

Only asm("....") was intended to be available for these sections. If we should make more available or not is an open question, so I'm going to put this a little on hold.

@Book-reader
Copy link
Contributor Author

Book-reader commented Feb 12, 2025

Only asm("....") was intended to be available for these sections

as in asm{} blocks weren't intended to be allowed in @naked functions?

@Book-reader
Copy link
Contributor Author

Book-reader commented Feb 12, 2025

oh, do you mean that @naked functions were intended to only be used with asm blocks and not regular code (even the unreachable() would be disallowed)?

@lerno
Copy link
Collaborator

lerno commented Feb 12, 2025

Yes

@lerno
Copy link
Collaborator

lerno commented Feb 12, 2025

Even more, only asm("...") with strings would be allowed.

@lerno lerno added this to the 0.6.8 milestone Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lower Priority This issue has lower priority for some reason
Projects
None yet
Development

No branches or pull requests

2 participants