When compiling the test with `gcc -std=c11 -fsyntax-only`
compilable/testcstuff1.c:98:23: warning: integer constant is so large that it is unsigned
98 | _Static_assert(sizeof(9223372036854775808) == 8, "ok");
| ^~~~~~~~~~~~~~~~~~~
compilable/testcstuff1.c:98:1: error: static assertion failed: "ok"
98 | _Static_assert(sizeof(9223372036854775808) == 8, "ok");
| ^~~~~~~~~~~~~~
Original test:
```
_Static_assert(sizeof(9223372036854775808) == 8, "ok");
```
Comment #1 by bugzilla — 2023-02-20T07:16:08Z
Shouldn't it be promoted to a long, rather than an unsigned?
Comment #2 by ibuclaw — 2023-02-20T11:54:32Z
(In reply to Walter Bright from comment #1)
> Shouldn't it be promoted to a long, rather than an unsigned?
That is certainly what our parser does as this is how D works.
Seems that it is undefined behaviour in C, as the test fails under gcc, but passes for clang.
https://godbolt.org/z/3hnjzMhfM
Should we add a `u` suffix to that literal? Probably, as I'm not comfortable us testing undefined behaviour in the testsuite - even though it is *precisely defined* for us in the D parser.
Maybe just document that we have a deterministic way of interpreting ambiguous integer literals in ImportC and be done with it.
Comment #3 by ibuclaw — 2023-02-20T11:58:34Z
(In reply to Iain Buclaw from comment #2)
> Seems that it is undefined behaviour in C, as the test fails under gcc, but
> passes for clang.
>
> https://godbolt.org/z/3hnjzMhfM
Note that both *do* give warnings about it though, to make it abundantly clear this is not strictly deterministic code.
Comment #4 by dlang-bot — 2023-11-27T08:18:07Z
@WalterBright created dlang/dlang.org pull request #3730 "fix Issue 23712 - ImportC: Unclear documentation of what type is infe…" fixing this issue:
- fix Issue 23712 - ImportC: Unclear documentation of what type is inferred from integer literals (type of 9223372036854775808 is undefined)
https://github.com/dlang/dlang.org/pull/3730
Comment #5 by dlang-bot — 2023-11-27T10:47:43Z
dlang/dlang.org pull request #3730 "fix Issue 23712 - ImportC: Unclear documentation of what type is infe…" was merged into master:
- 9bca33d060e4fa48f6ec7381472801122d8202f6 by Walter Bright:
fix Issue 23712 - ImportC: Unclear documentation of what type is inferred from integer literals (type of 9223372036854775808 is undefined)
https://github.com/dlang/dlang.org/pull/3730