-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang][C23] Crash when trying to use a constexpr
variable that could not be initialized
#109095
Comments
@llvm/issue-subscribers-clang-frontend Author: Anichitei Ionel-Cristinel (ianichitei)
I don't think I chose the best title, but I don't know how else to describe it, but the code is pretty straight forward: https://godbolt.org/z/1Tj8ba5bq
constexpr char c[] = { 'a' };
constexpr int i = c[1];
static_assert(i == c[0], "whatever"); When compiled with
Weirdly enough, it looks like adding some other flags avoids the crash, for example with |
Confirmed: https://godbolt.org/z/5PGzqeevv It crashes unconditionally w/ assertion build though: https://godbolt.org/z/7Wb5snbEo |
The problem here seems to be that due to variable being llvm-project/clang/lib/AST/ExprConstant.cpp Line 17277 in 7fa0d05
It seems logical to not return true from
However
In addition to the previous change in |
I think the larger refactoring makes more sense; ideally, the "high level" interfaces in the AST should be language agnostic because |
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
Before using a constexpr variable that is not properly initialized check that it is valid. Fixes llvm#109095 Fixes llvm#112516
I don't think I chose the best title, but I don't know how else to describe it, but the code is pretty straight forward: https://godbolt.org/z/1Tj8ba5bq
When compiled with
-std=c23
with clang 19.1.0 this happens:Weirdly enough, it looks like adding some other flags avoids the crash, for example with
-std=c23 -O3
: https://godbolt.org/z/41bGxqdh8 (it still crashes with-O3 -std=c23
).The text was updated successfully, but these errors were encountered: