From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 03D8F3848599; Mon, 16 May 2022 21:35:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03D8F3848599 From: "hello at josephloser dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105623] New: [12/13 regression][rejects valid] invalid use of auto when deducing return type of base class template Date: Mon, 16 May 2022 21:35:50 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hello at josephloser dot com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 21:35:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105623 Bug ID: 105623 Summary: [12/13 regression][rejects valid] invalid use of auto when deducing return type of base class template Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hello at josephloser dot com Target Milestone: --- The following code used to work in GCC 11.3.0, but fails on GCC 12.1.0 and trunk. ``` #include constexpr auto g(auto name_fn) { return name_fn(); } template struct ct_string { static constexpr char str[] =3D {Cs..., 0}; static constexpr auto name() { return std::string_view{str, sizeof...(C= s)}; } }; struct S : ct_string<'f', 'o', 'o'> { constexpr auto f() { return g(name); } }; int main() { { S s; [[maybe_unused]] constexpr auto name =3D s.f(); } return 0; } ``` This code works on GCC 11.3.0 but fails on GCC 12.1.0 onward, including tru= nk. See it live at https://godbolt.org/z/9c8vb1eP5 One workaround is to explicitly provide the return type for `ct_string::foo` static function such as at https://godbolt.org/z/ccqPxoM5P which works on G= CC 11.3.0, 12.1.0, and trunk.=