| Issue |
175589
|
| Summary |
[Clang] Clang crash when applying __builtin_classify_type to a pointer-to-member of a function template
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Attacker23
|
The following code causes crash on x86-64 clang since 6.0.0, but it doesn’t crash on 12–16:
### Minimal Reproduction
```cpp
struct C {
template<class T>
void f() {}
};
static_assert(__builtin_classify_type(&C::f));
```
Clang crashes when __builtin_classify_type is used on &C::f, where f is a member function template
Instead of rejecting the _expression_ as ill-formed (as GCC/EDG do), Clang goes into constant evaluation of __builtin_classify_type’s argument and crashes while trying to treat &C::f as a valid pointer in a constant _expression_.
### Compiler Explorer
**https://godbolt.org/z/KasWqvsvd**
### Compiler Output
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
#0 0x0000000003d649e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d649e8)
#1 0x0000000003d623bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d623bc)
#2 0x0000000003ca74b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072eb5a442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00000000074f9d98 clang::Expr::EvalResult::isGlobalLValue() const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x74f9d98)
#5 0x000000003c6b4a40
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs