tbaederr wrote:

Unrelated to compound literals; In C23 we shouldn't allow reading from a 
non-constexpr variable if we're in a constant context.

For your example:
```c++
const int a = 1;
constexpr int b = a;
```
we disallow this here: 
https://github.com/llvm/llvm-project/blob/ef69409b93d30c3a92bba1431e8bffe5cd3a8c4e/clang/lib/AST/ExprConstant.cpp#L4842-L4844

That's because `ConstexprVar` is set, because we're getting here through 
`EvalauteAsInitializer`. But it seems like that condition isn't correct and we 
need to check `Info.getLangOpts().C23 && Info.InConstantContext` instead.

That's just a guess though, I haven't verified that this doesn't break any 
existing tests.



https://github.com/llvm/llvm-project/pull/232825
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to