struct A {
constexpr static int value = 0;
};
void func(A& _) {
constexpr auto result = _.value;
}
auto main() -> int {
A a;
func(a);
}
error message:
<source>:6:18: error: constexpr variable 'result' must be initialized by a constant expression
6 | constexpr auto result = _.value;
| ^ ~~~~~~~
<source>:6:27: note: function parameter '_' with unknown value cannot be used in a constant expression
6 | constexpr auto result = _.value;
| ^
<source>:5:14: note: declared here
5 | void func(A& _) {
| ^
```cpp
struct A {
constexpr static int value = 0;
};
void func(A& _) {
constexpr auto result = _.value;
}
auto main() -> int {
A a;
func(a);
}
```
#### error message:
```txt
<source>:6:18: error: constexpr variable 'result' must be initialized by a constant expression
6 | constexpr auto result = _.value;
| ^ ~~~~~~~
<source>:6:27: note: function parameter '_' with unknown value cannot be used in a constant expression
6 | constexpr auto result = _.value;
| ^
<source>:5:14: note: declared here
5 | void func(A& _) {
| ^
```
#### Additional Information:
Version: clang version 18.1.8
Link: [godbolt](https://godbolt.org/z/xYWfx48sT)
PS: The code compiles successfully on gcc and msvc.
error message:
Additional Information:
Version: clang version 18.1.8 Link: godbolt
PS: The code compiles successfully on gcc and msvc.