dtcxzyw wrote: > Does it even make sense for evaluateValue to return a constexpr-unknown > value? If I'm following correctly, we can't actually do anything useful with > such a result: we don't actually know what the value is. It would make things > simpler if we kept such APValues as an internal implementation detail of > ExprConstant.
Clang rejects the following case after modifying `evaluateValue` to treat constexpr-unknown value as invalid: https://godbolt.org/z/5K9vvnscT ``` struct Bottom { constexpr Bottom() {} }; struct Base : Bottom { constexpr Base(int a = 42, const char *b = "test") : a(a), b(b) {} int a; const char *b; }; struct Base2 : Bottom { constexpr Base2(const int &r) : r(r) {} int q = 123; const int &r; }; struct Derived : Base, Base2 { constexpr Derived() : Base(76), Base2(a) {} int c = r + b[1]; }; constexpr Derived derived; constexpr Bottom &bot2 = (Base2&)derived; constexpr Base2 &ok2 = (Base2&)bot2; ``` ``` File /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/clang/test/SemaCXX/constant-expression-cxx11.cpp Line 936: constexpr variable 'ok2' must be initialized by a constant expression ``` https://github.com/llvm/llvm-project/pull/127525 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits