From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3D1E384B806; Thu, 27 Oct 2022 15:20:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3D1E384B806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666884001; bh=+R8zZFOUoN+4JA0TJ6pNU9rE7G9y4YO74IPRty6wWqM=; h=From:To:Subject:Date:From; b=xpgi+3Op9U3N2lL2kQzhDZr/7kQxlwPy+rNJa6pVjoH/fEURHZGDQe5rn7nNOFEx8 ROGRCYhr9ehYkPM1IyQ3k9+1p9gN8A7mgduM2xOie6z73o8DvWD3ovxOWDs+HE1izL wnzTPje7QMSf8sin8bvpOz3X04OwV4WjzUuD6zzs= From: "development at jordi dot vilar.cat" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107437] New: nested generic lambdas fail requiring unneded captures Date: Thu, 27 Oct 2022 15:20:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: development at jordi dot vilar.cat X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107437 Bug ID: 107437 Summary: nested generic lambdas fail requiring unneded captures Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: development at jordi dot vilar.cat Target Milestone: --- This simple valid code fails to compile with all recent versions of gcc, but compiles nicely with clang (and even msvc!) (live demo on complier explorer: https://godbolt.org/z/eM1b9e6s9) // compile with just -std=3Dc++20 #include #include #include void test() { std::invoke([](auto N, std::type_identity) { using vector_type =3D std::array; static_assert(N =3D=3D std::tuple_size_v); std::invoke([](std::index_sequence) { =20=20=20=20=20=20=20=20=20=20=20 static_assert(std::conjunction_v, T>...>); }, std::make_index_sequence{}); }, std::integral_constant{}, std::type_identity{}); } It issues the diagnostics output: : In instantiation of 'test()::)> [with T =3D int; auto:3 =3D std::integral_constant]': /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/type_traits:2565:26:= =20=20 required by substitution of 'template static std::__result_of_success()((declval<_Args>)()...)), std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =3D test()::)>; _Args =3D {std::integral_constant, std::type_identity}]' /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/type_traits:2576:55:= =20=20 required from 'struct std::__result_of_impl)>, std::integral_constant, std::type_identity >' /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/type_traits:2581:12:= =20=20 required from 'struct std::__invoke_result)>, std::integral_constant, std::type_identity >' /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/type_traits:3022:12:= =20=20 required from 'struct std::invoke_result)>, std::integral_constant, std::type_identity >' /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/type_traits:3034:11:= =20=20 required by substitution of 'template using invoke_result_t =3D typename std::invoke_result::type [with _Fn =3D test()::)>; _Args =3D {std::integral_constant, std::type_identity}]' /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/functional:107:5:=20=20 required by substitution of 'template constexpr std::invoke_result_t<_Fn, _Args ...> std::invoke(_Callable&&, _Ar= gs&& ...) [with _Callable =3D test()::)>; _= Args =3D {std::integral_constant, std::type_identity}]' :7:16: required from here :13:32: error: 'N' is not captured 13 |=20=20=20=20=20=20=20=20=20=20=20=20 static_assert(std::conjunction_v, T>...>); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :11:21: note: the lambda has no capture-default 11 | std::invoke([](std::index_sequence) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 | { | ~=20=20=20=20=20=20=20=20=20=20=20=20 13 |=20=20=20=20=20=20=20=20=20=20=20=20 static_assert(std::conjunction_v, T>...>); |=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~ 14 | }, std::make_index_sequence{}); | ~=20=20=20=20=20=20=20=20=20=20=20=20 :7:37: note: 'std::integral_constant N' decla= red here 7 | std::invoke([](auto N, std::type_identity) | ~~~~~^=