From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CAAFF3858C74; Sat, 12 Aug 2023 19:28:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAAFF3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691868517; bh=WRLN2j5v8IJLbgHsCmYw/D0tJk+uLkfMSsY6glF3hF8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OlQRH4U0fdZBF9HWNU45LOZN6Dwhr+LoJTCu75xNIV/JganQQ6OY0j7Xet0s7+UI+ QciKWAuo2UksWbOyIbqcgTelfcqAZD64bfYBpNHaIlE2w1B6PAq83kbN067bh3LiDG Zqax3gKzyoMoo3NsByFoR2asB5x53RRMj3FCX3Ho= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111004] Visitor and concept error message Date: Sat, 12 Aug 2023 19:28:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: Message-ID: In-Reply-To: References: 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=3D111004 --- Comment #1 from Andrew Pinski --- Clang's error message is similarly "bad" with GCC's libstdc++: ``` :24:5: error: no matching function for call to 'visit' 24 | std::visit([](My_concept auto &&arg) { std::cout << "OK\n"; }, = v); | ^~~~~~~~~~ /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../.= ./../include/c++/14.0.0/variant:1867:5: note: candidate template ignored: couldn't infer template argument '_Res' 1867 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^ /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../.= ./../include/c++/14.0.0/variant:1827:5: note: candidate template ignored: substitution failure [with _Visitor =3D (= lambda at :24:16), _Variants =3D &>]: no type named 'type' = in 'std::invoke_result<(lambda at :24:16), A &>' 1827 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^ ``` Now LLVM's libc++ produces something which might be helpful: ``` In file included from :2: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/iostream:= 43: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/ios:222: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__locale:= 21: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/mutex:192: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__conditi= on_variable/condition_variable.h:17: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__mutex/u= nique_lock.h:17: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__system_= error/system_error.h:14: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__system_= error/error_category.h:15: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/string:62= 2: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/string_vi= ew:1059: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/algorithm= :1960: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/iterator:= 683: In file included from /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/__iterato= r/common_iterator.h:31: /opt/compiler-explorer/clang-trunk-20230812/bin/../include/c++/v1/variant:6= 80:19: error: static assertion failed due to requirement 'is_invocable_v<(lambda at :24:16), A &>': `std::visit` requires the visitor to be exhaustive. 680 | static_assert(is_invocable_v<_Visitor, _Values...>, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... ``` But still no mention of why=