-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Labels
c++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluationlambdaC++11 lambda expressionsC++11 lambda expressionsregressionrejects-valid
Description
The following used to compile without diagnostic in Clang 20.1:
template<class T, class U>
struct is_same {
static constexpr bool value = false;
};
template<class T>
struct is_same<T, T> {
static constexpr bool value = true;
};
template <typename T, int N>
struct A {
static_assert([]() constexpr { // error: value of type 'void' is not contextually convertible to 'bool'
if constexpr (is_same<T, int>::value)
return true;
else
return (10 != N);
}());
};
int f1() {
if constexpr (false) {
A<int, 256> a;
}
return 0;
} but now gives an error on trunk: https://godbolt.org/z/fd5WY4xhY
Note, if you remove the if constexpr (false) from f1(), then the code compiles. If you add -> bool to the lambda, the code also compiles.
The code compiles without diagnostics in GCC, MSVC, and EDG.
Metadata
Metadata
Assignees
Labels
c++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluationlambdaC++11 lambda expressionsC++11 lambda expressionsregressionrejects-valid