| Issue |
181569
|
| Summary |
clang -Wunreachable-code triggers on instantiation of classes with [[noreturn]] constructors
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
sdutoit
|
Reproducer -- [godbolt](https://gcc.godbolt.org/z/5G5f5E5GY):
Compiling
```cpp
#include <stdlib.h>
template <typename Args> struct NoReturn {
[[noreturn]] NoReturn() {
exit(123);
}
};
int main(int argc, char** argv) {
NoReturn<int> n;
}
```
With `-std=c++26 -Wunreachable-code` this yields the following warning, while the code clearly does execute:
```
<source>:10:5: warning: code will never be executed [-Wunreachable-code]
10 | NoReturn<int> n;
| ^~~~~~~~~~~~~~~~
1 warning generated.
Execution build compiler returned: 0
Program returned: 123
```
I've reproduced this locally and on godbolt with `21.1.8`, `21.1.0` and `20.1.0`. It does not reproduce with `19.1.0`.
(and yes, I have a real use case for `[[noreturn]]` constructors! :) )
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs