| Issue |
183289
|
| Summary |
[Clang] Static constexpr member of a class not considered as constexpr in lambda's auto parameter
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
kiroma
|
The following example (https://godbolt.org/z/ecKjhc793) compiles on gcc and msvc with no warnings:
```cpp
template<unsigned V>
struct Foo
{
static constexpr unsigned Value = V;
};
int main()
{
[](auto&& f)
{
if constexpr(f.Value == 1)
{
throw 1;
}
}(Foo<1>{});
}
```
But results in the following error on clang:
```
<source>:11:22: error: constexpr if condition is not a constant _expression_
11 | if constexpr(f.Value == 1)
| ^~~~~~~~~~~~
<source>:15:6: note: in instantiation of function template specialization 'main()::(lambda)::operator()<Foo<1>>' requested here
15 | }(Foo<1>{});
| ^
<source>:11:22: note: function parameter 'f' with unknown value cannot be used in a constant _expression_
11 | if constexpr(f.Value == 1)
| ^
<source>:9:15: note: declared here
9 | [](auto&& f)
| ^
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs