Issue 63902
Summary Can not use `ref.static_member` in constant _expression_
Labels
Assignees
Reporter namniav
    https://godbolt.org/z/PfG7e31Kx

```c++
struct Foo {
  static constexpr int value = 1;
};


int main() {
 // OK
    Foo foo;
    static_assert(foo.value > 0);

    // Clang error
    Foo& ref = foo;
    static_assert(ref.value > 0);
}
```

> ```
> <source>:13:19: error: static assertion _expression_ is not an integral constant _expression_
>    13 | static_assert(ref.value > 0);
>       | ^~~~~~~~~~~~~
> <source>:13:19: note: initializer of 'ref' is not a constant _expression_
> <source>:12:10: note: declared here
>    12 | Foo& ref = foo;
>       |          ^
> 1 error generated.
> Compiler returned: 1
> ```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to