Issue |
143613
|
Summary |
C23 Clang rejects valid code involving compound literal and typeof
|
Labels |
clang
|
Assignees |
|
Reporter |
dcawley15
|
I was attempting to create a generic bit cast macro using the new C23 typeof feature. Clang appears to reject the following code with "_error: initializer element is not a compile-time constant_" even though I believe this code is valid in C23. Both GCC and MSVC (with /std:clatest) accept this code.
``` c
#include <stdint.h>
#define bitcast(type, value) \
(((union{ typeof(value) src; type dst; }){ (value) }).dst)
int main(void)
{
int64_t foo = 4;
double bar = bitcast(double, foo); // ok
foo = bitcast(int64_t, bar); // ok
foo = bitcast(int64_t, bitcast(double, foo)); // error
return 0;
}
```
Compiler Flags: -std=c23 -pedantic
https://godbolt.org/z/zsfErTo1e
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs