From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 46C1D3858D32; Wed, 27 Dec 2023 17:38:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46C1D3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703698727; bh=DuAtF6g/oss6rjHwRmtTo8dmUiP6o+VdyLodUni8PhU=; h=From:To:Subject:Date:From; b=BL9LV/6VY6t9+nlBSWb0qWebtfyQja5N5TnUXcPolBg72OBW3Cs0gARTWCKv/HKSN im3MotJLIRCReGVpmlrE/0R/ATvE6C0FCMHoEMTIzl+3ZUGGGTkSgl4GGAx+hRmapY OJHdTiihWWBQ3qoKFJ/t9qTt+oZREx9v24g+2J1o= From: "sim.f.nilsson at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113158] New: Erroneous "looser exception specification" error for class template Date: Wed, 27 Dec 2023 17:38:46 +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.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sim.f.nilsson at gmail 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113158 Bug ID: 113158 Summary: Erroneous "looser exception specification" error for class template Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sim.f.nilsson at gmail dot com Target Milestone: --- The following code is not accepted by GCC 13.2.0 (among other versions): #include struct base { virtual int f() const =3D 0; }; template struct derived : base { int f() const noexcept(std::is_nothrow_copy_constructible_v) override { return sizeof(T); } }; int g() { return derived{}.f(); } I've tested versions 9 through 13 and trunk. Version 9.5 seems to be the la= st version that accepts the code. The code is accepted by both Clang and MSVC.= To the best of my knowledge Clang and MSVC are correct to accept the code as base::f is a "potentially throwing function" without the noexcept specifier. What flags are used when compiling the code does not seem to influence the behaviour, but for reference I've mostly used '-Wall -Wextra -O1 -std=3Dc++= 17' in comparisons. The following compiler-explorer link also demonstrates the error: https://compiler-explorer.com/z/1c48Yr76P Adding 'noexcept(false)' in the base-class declaration of f, or either 'noexcept' or 'noexcept(false)' to the derived definition, makes GCC accept= it.=