Issue |
141797
|
Summary |
`[[gnu::weak]]` disables constant evaluation of constexpr variables in C++14
|
Labels |
good first issue,
c++11,
c++14,
clang:frontend,
diverges-from:gcc
|
Assignees |
|
Reporter |
cor3ntin
|
GCC and Clang disagree on their handling of `[[gnu::weak]]` before C++17 https://gcc.godbolt.org/z/s7q67vqjz
```cpp
struct S { static constexpr int var = 0; };
[[gnu::weak]] constexpr int S::var;
static constexpr int usage = S::var;
```
While it would be unsafe to constant-fold this code, it should be fine to constant-evaluate it, for consistency with GCC
In `static bool evaluateVarDeclInit` (ExprConstant.cpp), and in `static bool CheckWeak` (`Interp.cpp`), we should allow constant evaluation -without diagnostics, but not constant folding) - by looking at `Info.EvalMode`
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs