https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106398
Bug ID: 106398 Summary: ICE in finish_expr_stmt at cp/semantics.c:872 for lambda with conditional noexcept against lambda in unevaluated context Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jbassett271 at gmail dot com Target Milestone: --- This ICEs: #define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) template <bool B> struct bool_t { static constexpr bool value = B; }; template <typename T> struct set { bool contains(T const&) const { return true; } }; template <typename T> void intersect(set<T> const& lhs, set<T> const& rhs) { auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] { return bool_t<noexcept(rhs.contains(_1))>{}; }(FWD(_1)))::value) { return rhs.contains(_1); }; f(1); } int main() { set<int> a, b; intersect(a, b); } #define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) template <bool B> struct bool_t { static constexpr bool value = B; }; template <typename T> struct set { bool contains(T const&) const { return true; } }; template <typename T> void intersect(set<T> const& lhs, set<T> const& rhs) { auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] { return bool_t<noexcept(rhs.contains(_1))>{}; }(FWD(_1)))::value) { return rhs.contains(_1); }; f(1); } int main() { set<int> a, b; intersect(a, b); } #define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) template <bool B> struct bool_t { static constexpr bool value = B; }; template <typename T> struct set { bool contains(T const&) const { return true; } }; template <typename T> void intersect(set<T> const& lhs, set<T> const& rhs) { auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] { return bool_t<noexcept(rhs.contains(_1))>{}; }(FWD(_1)))::value) { return rhs.contains(_1); }; f(1); } int main() { set<int> a, b; intersect(a, b); } #define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) template <bool B> struct bool_t { static constexpr bool value = B; }; template <typename T> struct set { bool contains(T const&) const { return true; } }; template <typename T> void intersect(set<T> const& lhs, set<T> const& rhs) { auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] { return bool_t<noexcept(rhs.contains(_1))>{}; }(FWD(_1)))::value) { return rhs.contains(_1); }; f(1); } int main() { set<int> a, b; intersect(a, b); } #define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) template <bool B> struct bool_t { static constexpr bool value = B; }; template <typename T> struct set { bool contains(T const&) const { return true; } }; template <typename T> void intersect(set<T> const& lhs, set<T> const& rhs) { auto f = [&]<typename T1>(T1&& _1) noexcept(decltype([] { return bool_t<noexcept(rhs.contains(_1))>{}; }(FWD(_1)))::value) { return rhs.contains(_1); }; f(1); } int main() { set<int> a, b; intersect(a, b); } https://godbolt.org/z/hPYP8s9W7 I've seen this ICE on several versions of GCC, including 11.1.0, 10.3.0, and this 12.1.1. This is possibly https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105692, but I don't know enough to deduplicate. This may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101043.