https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64977
--- Comment #2 from ytj000 at gmail dot com ---
(In reply to Martin Sebor from comment #1)
> I'm not 100% sure this example is valid. It seems to me that the rejected
> initializer "e" is invalid because it's not
> a core constant expression. I.e., it's a capture by reference, which is "an
> id-expression that refers to a variable or data member of reference type
> [that] has a preceding initialization" but the reference isn't "initialized
> with a constant expression" (a is not a constant expression). Is there
> something I'm missing?
I think you are right. The following code shows clang has inconsistent
behavior.
struct A {
constexpr operator int() const { return 0; }
};
int main() {
A a;
[&a]() { constexpr int b = a; }; // clang accepted
A &ra = a;
constexpr int b = ra; // clang rejected
}