| Issue |
172118
|
| Summary |
[C23] Type of enumeration constants having enumerated type wrong in C
|
| Labels |
c23,
clang:frontend,
diverges-from:gcc
|
| Assignees |
|
| Reporter |
hubert-reinterpretcast
|
Clang uses the wrong type for enumeration constants having enumerated type. It uses the underlying type instead.
This causes missing `-Wswitch` warnings (for example). https://godbolt.org/z/rKnndKdvo
### Source (`<stdin>`):
```c
typedef enum : long { E0 } E;
void f(bool b, E e) {
auto v = E0;
if (b) v = e;
switch (v) {} // expected-warning {{not handled in switch}}
}
```
### Compiler invocation:
```
clang -std=c23 -Wall -Wextra -pedantic -Xclang -verify -xc -
```
### Expected output:
(clean compile)
### Actual output:
```
error: 'expected-warning' diagnostics expected but not seen:
File <stdin> Line 5: not handled in switch
1 error generated.
```
### Compiler version info (`clang -v`):
```
clang version 22.0.0git (https://github.com/llvm/llvm-project.git d8d87b594eb67c1f96cf59d645b660f8fd831bee)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs