From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 55129385803D; Fri, 6 May 2022 00:12:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55129385803D From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105499] New: inconsistency between -Werror=c++-compat and g++ in __extension__ block Date: Fri, 06 May 2022 00:12:51 +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.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincent-gcc at vinc17 dot net 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: Fri, 06 May 2022 00:12:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105499 Bug ID: 105499 Summary: inconsistency between -Werror=3Dc++-compat and g++ in __extension__ block Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- Consider int *f (void *q) { return __extension__ ({ int *p =3D q; p; }); } With GCC 11.3.0 under Debian (Debian package), I get the following: $ gcc -Werror=3Dc++-compat -c tst.c $ g++ -c tst.c tst.c: In function =E2=80=98int* f(void*)=E2=80=99: tst.c:3:36: error: invalid conversion from =E2=80=98void*=E2=80=99 to =E2= =80=98int*=E2=80=99 [-fpermissive] 3 | return __extension__ ({ int *p =3D q; p; }); | ^ | | | void* so no errors with "gcc -Werror=3Dc++-compat", but an error with g++. This i= s not consistent. Either this is regarded as a valid extension in C++ so that both should succeed, or this is not valid C++ code even in __extension__ so that both should fail. Same issue with various GCC versions from 4.9 to 11.3.0. AFAIK, the purpose of -Wc++-compat is to test whether code would still pass when replacing C compilation by C++ (there might be false positives or false negatives, but this should not be the case with the above example). FYI, I got the above issue while testing GNU MPFR (tested with -Werror=3Dc++-compat first, and with g++ a bit later in a more extensive te= st).=