From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70A693840C03; Mon, 22 Jun 2020 03:21:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70A693840C03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592796061; bh=HLdO+O59zqWMO/cOQe8A8yODL0KoonBueN1XLtZeAJk=; h=From:To:Subject:Date:From; b=pPU7UcgkVXxabNJO1RxByvrJpHQetPyaHFwBurFFXkECRdTb4x9X7EUVVsN38pJm5 UEpsEM/dCKiaJcH7NpClb+aiYFTLL4wL35IfnrPc3Fn7J7JFHJdp1qeETJdTwZEyX0 elH3fGXrjYjnHW54GMq2BGHgzgsxQvqB1JM7yArE= From: "haoxintu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95807] New: GCC accepts "void value not ignored as it ought to be" in function template Date: Mon, 22 Jun 2020 03:21: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: 11.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: haoxintu 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 keywords 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, 22 Jun 2020 03:21:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95807 Bug ID: 95807 Summary: GCC accepts "void value not ignored as it ought to be" in function template Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- GCC accepts "void value not ignored as it ought to be" in a function templa= te but rejects it in a normal function definition.=20 $cat bug.cc void foo1() {int var =3D throw;}; template =20 void foo2() {int var =3D throw;}; $g++ -c bug.cc bug.cc: In function =E2=80=98void foo()=E2=80=99: bug.cc:1:23: error: void value not ignored as it ought to be 1 | void foo1() {int var =3D throw;}; | ^~~~~ Noted that GCC only rejects line 1 but accepts line 3. In clang $clang++ -c bug.cc bug.cc:1:18: error: cannot initialize a variable of type 'int' with an rval= ue of type 'void' void foo1() {int var =3D throw;}; ^ ~~~~~ bug.cc:3:18: error: cannot initialize a variable of type 'int' with an rval= ue of type 'void' void foo2(){ int var =3D throw;}; ^ ~~~~~ 2 errors generated. My GCC version is $g++ --version g++ (GCC) 11.0.0 20200605 (experimental) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=