https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101043
Bug ID: 101043 Summary: ICE in check_noexcept_r for lambda conditional noexcept via requires expression Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jbassett271 at gmail dot com Target Milestone: --- GCC has an internal compiler error for requires expressions inside the noexcept clause of a lambda inside a templated function: https://godbolt.org/z/oWhq9sf8M 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(requires { { rhs.contains(_1) } noexcept; }) { return rhs.contains(_1); }; } int main() { set<int> lhs; set<int> rhs; intersect(lhs, rhs); } Error message: <source>: In instantiation of 'void intersect(const set<T>&, const set<T>&) [with T = int]': <source>:18:21: required from here <source>:9:7: internal compiler error: in check_noexcept_r, at cp/except.c:1123 9 | { rhs.contains(_1) } noexcept; | ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. The commandline arguments, according to the Compiler Explorer link (cleaned a little): -g -o output.s -masm=intel -S -fdiagnostics-color=always -std=c++20 example.cpp Clang compiles this fine. I was able to replicate this bug in GCC versions 10.1, 10.2, 10.3, and 11.1.