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

"array element types do not match" error with certain literals. #16

Closed
calroc opened this issue Mar 10, 2023 · 5 comments
Closed

"array element types do not match" error with certain literals. #16

calroc opened this issue Mar 10, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@calroc
Copy link
Contributor

calroc commented Mar 10, 2023

I've been busy the last couple of days, but I sat down this evening to fiddle with fixed point 3D math and discovered something odd while building a table of sin values.

Contents of t.c:

u64 a[2] = {0x7fff8beb, 0x8000e82a};

Result of attempting to compile:

uvm/ncc % cargo run ./examples/t.c
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/ncc ./examples/t.c`
Error: array element types do not match

I tried with 0xffffffff and 0x100000000 on the theory that it might have something to do with having literal values of both 31 and 32 bits, respectively, in the same initializer. But with that pair of initial values the program compiles without the error message.

@maximecb maximecb added the bug Something isn't working label Mar 10, 2023
@maximecb
Copy link
Owner

In C, int literals have type int if they can fit in the int32 range, and type long otherwise. That's probably why it's complaining.

That being said, your code should work. I'll start working on a fix :)

@maximecb
Copy link
Owner

Should be all fixed now :)

@maximecb maximecb self-assigned this Mar 10, 2023
@calroc
Copy link
Contributor Author

calroc commented Mar 10, 2023

In C, int literals have type int if they can fit in the int32 range, and type long otherwise. That's probably why it's complaining.

I figured, that's why I thought it was odd that {0xffffffff, 0x100000000} didn't generate the same error message.

Anyway, it is fixed now, thank you very much! :)


(Ugh! I just noticed I wrote "31 and 32 bits" in the original comment, d'oh! I meant of course 32 and 33.)

@calroc calroc closed this as completed Mar 10, 2023
@maximecb
Copy link
Owner

Let me know if you run into other problems and I'll try to fix them quickly, especially if they're easy to fix.

@calroc
Copy link
Contributor Author

calroc commented Mar 10, 2023

Will do! Cheers!

That other bug I mentioned in the UVM Wishlist #7 issue turns out not to be related to #define at all. I'll open an issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants