Bug 23694 – compilable/ctests2.c:51:9: error: initializer element is not constant

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2023-02-12T14:57:10Z
Last change time
2023-02-21T09:35:40Z
Keywords
accepts-invalid, ImportC, pull
Assigned to
No Owner
Creator
Iain Buclaw
Depends on
23689
See also
https://issues.dlang.org/show_bug.cgi?id=23689, https://issues.dlang.org/show_bug.cgi?id=23700

Comments

Comment #0 by ibuclaw — 2023-02-12T14:57:10Z
When compiling the test with `gcc -std=c11 -fsyntax-only` compilable/cppflags.c:4:16: error: ‘ABC’ undeclared here (not in a function) 4 | _Static_assert(ABC == 3, "1"); | ^~~ compilable/cppflags.c:4:16: error: expression in static assertion is not an integer Original test content: ``` /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22398 const int a; int b = a; ```
Comment #1 by ibuclaw — 2023-02-16T22:23:21Z
This is somewhat documented on https://dlang.org/spec/importc.html#ctfe Perhaps some examples of what ImportC can do vs. GCC.
Comment #2 by ibuclaw — 2023-02-16T22:26:28Z
(In reply to Iain Buclaw from comment #0) > compilable/cppflags.c:4:16: error: ‘ABC’ undeclared here (not in a function) > 4 | _Static_assert(ABC == 3, "1"); > | ^~~ > compilable/cppflags.c:4:16: error: expression in static assertion is not an > integer Actual error compilable/ctests2.c: At top level: compilable/ctests2.c:51:9: error: initializer element is not constant 51 | int b = a; | ^
Comment #3 by dlang-bot — 2023-02-21T07:26:45Z
@WalterBright created dlang/dlang.org pull request #3535 "fix Issue 23694 and Issue 23700 Document ImportC CTFE" fixing this issue: - fix Issue 23694 and Issue 23700 Document ImportC CTFE https://github.com/dlang/dlang.org/pull/3535
Comment #4 by dlang-bot — 2023-02-21T07:53:42Z
dlang/dlang.org pull request #3535 "fix Issue 23694 and Issue 23700 Document ImportC CTFE" was merged into master: - f89e67a7d88bc5792d2dec37620ab49180edc60a by Walter Bright: fix Issue 23694 and Issue 23700 Document ImportC CTFE https://github.com/dlang/dlang.org/pull/3535
Comment #5 by ibuclaw — 2023-02-21T09:35:40Z
*** Issue 23700 has been marked as a duplicate of this issue. ***