| Issue |
244868
|
| Summary |
Assertion failed at `clang::StringLiteral::getString (isUnevaluated() || getCharByteWidth() == 1) && "This function is used in places that assume strings use char"`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
haoxintu
|
## Description
```c
int main(void) {
if (__builtin_cpu_supports(L"wide")
```
```
$ clang -O0 -c repro.c # also -O1, -O2, -O3, -Os
repro.c:2:30: error: incompatible pointer types passing 'int[5]' to parameter of type 'const char *' [-Wincompatible-pointer-types]
clang: /home/haoxin/research/llvm-project/clang/include/clang/AST/Expr.h:1913: llvm::StringRef clang::StringLiteral::getString() const: Assertion `(isUnevaluated() || getCharByteWidth() == 1) && "This function is used in places that assume strings use char"' failed.
0. Program arguments: clang -O0 -c repro.c -o /dev/null
1. repro.c:2:37: current parser token ')'
2. repro.c:1:16: parsing function body 'main'
3. repro.c:1:16: in compound statement ('{}')
clang: error: clang frontend command failed due to signal (use -v to see invocation)
```
The program isn't valid C (the reference compiler rejects it), but I think the compiler should diagnose it rather than crash.
Reproduced in Godbolt (x86-64 clang assertions trunk, -O0): https://godbolt.org/z/hjna4jsbW
## Checked Versions
- Crash at -O0/-O1/-O2/-O3/-Os with clang version 24.0.0git (https://github.com/llvm/llvm-project.git 2012344e5da8e03ea4b8283ecd6fad6e13f09d64).
- clang 23.1 works well, so it seems to be a recent regression issue.
Thanks.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs