Issue |
120503
|
Summary |
[Clang] constexpr variables wrongfully treated as captures
|
Labels |
clang
|
Assignees |
|
Reporter |
yuxuanchen1997
|
Clang currently rejects the following program by saying "error: variable 'XXXcap' cannot be implicitly captured in a lambda with no capture-default specified"
```
template <typename...>
struct tag_t {};
template <auto...>
struct vtag_t {};
template <auto... V>
inline constexpr vtag_t<V...> vtag{};
template <typename T>
constexpr bool alt = true;
template <typename = void>
auto vtag_safety_of_non_stored_args() {
return []<typename T>(tag_t<T>) {
return vtag<[]() {
constexpr bool XXXcap = alt<T>;
if constexpr (XXXcap) {
return vtag<>;
} else {
return vtag<XXXcap>;
}
}>;
}(tag_t<int>{});
}
void check() {
vtag_safety_of_non_stored_args();
}
```
This seems wrong. As `XXXcap` here is not a capture. GCC and MSVC seem to have no problem with this.
See compiler explorer: https://godbolt.org/z/7rqcfGe7x
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs