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

The compiler encountered an unexpected error #1927

Open
DanyDollaro opened this issue Feb 4, 2025 · 3 comments
Open

The compiler encountered an unexpected error #1927

DanyDollaro opened this issue Feb 4, 2025 · 3 comments
Assignees
Labels
Revisit later Revisit this issue at a later point

Comments

@DanyDollaro
Copy link
Contributor

DanyDollaro commented Feb 4, 2025

Trying to compile the following code:

fn int main(String[] args)
{
    char[12] buffer;

    asm
    {
        movl [&buffer + 0], $ebx;
    }

    return 0;
}

C3C generate the following output:

D:\Solutions\C3\test>c3c build
⚠️ The compiler encountered an unexpected error: "TODO reached".

- Function: sema_check_asm_arg_addr(...)
- Source file: D:\a\c3c\c3c\src\compiler\sema_asm.c:206

🙏 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.

but it compiles fine when I remove the "+ 0":

fn int main(String[] args)
{
    char[12] buffer;

    asm
    {
        movl [&buffer], $ebx;
    }

    return 0;
}

I am on windows an I compiled with the latest release (0.6.6)

@DanyDollaro
Copy link
Contributor Author

DanyDollaro commented Feb 4, 2025

I don't quite understand if this is not supposed to happen or if I am missing something, there seems to be something wrong, also if I try to compile this:

fn int main(String[] args)
{
    char[12] buffer;
    asm("movl [&buffer], $ebx");

    return 0;
}

I get:

D:\Solutions\C3\test>c3c build
LLVM ERROR: Bad $ operand number in inline asm string: 'movl [&buffer], $ebx'

As last, it works if i do char* ptr = &buffer; and use ptr into the assembly code instead of &buffer

@lerno
Copy link
Collaborator

lerno commented Feb 4, 2025

The second is obvious why it doesn't work at least: text asm doesn't understand its surroundings.

Looking through the asm code will take a little while because I have to read through it to remember how it worked. Also, I had contributors to it making it less familiar to my eyes as well.

@lerno lerno self-assigned this Feb 4, 2025
@lerno lerno added the Revisit later Revisit this issue at a later point label Feb 9, 2025
@lerno
Copy link
Collaborator

lerno commented Feb 9, 2025

This needs to be done with all the other ASM fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Revisit later Revisit this issue at a later point
Projects
None yet
Development

No branches or pull requests

2 participants