From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 754A83861038; Sat, 5 Sep 2020 11:13:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 754A83861038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599304396; bh=qq52uHEUA5782bD2ahTieJoxz+6LjKsYlFqkFmx1gyk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pzr5pnm9Zm64O53OIcbHotb1E/Dio8y3VkLOu11ZACYSd09dm1AywNh7o9YFE0sXq O6WSmR+B+3w6uEhEc8BLitDE5CXtUQO1BpRcDz0JVg7u8w/jJMvFhE01xVToMHPKH3 rhf/7VLCSV2QCXOfAUhwvJqskO6kQGTZph0AN0/Q= From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60304] Including disables -Wconversion-null in C++ 98 mode Date: Sat, 05 Sep 2020 11:13:15 +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: 4.8.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: harald at gigawatt dot nl X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED 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 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: Sat, 05 Sep 2020 11:13:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D60304 --- Comment #31 from Harald van Dijk --- (In reply to Jonathan Wakely from comment #30) > I'm curious why the preprocessed code in comment 28 doesn't warn, This was still bugging me, so I looked into it a little bit, and since I had trouble finding this written down somewhere I thought it would be worth including here. The line "# 2 "b.C" 3 4" means that what follows is line 2 = of b.C, and b.C is a C system header. The relevant bits of GCC code to see this are =20 https://github.com/gcc-mirror/gcc/blob/releases/gcc-10.2.0/libcpp/directive= s.c#L1061 =20 https://github.com/gcc-mirror/gcc/blob/releases/gcc-10.2.0/libcpp/internal.= h#L358 So this means that "false" is coming from a system header. It is: it is com= ing from the macro expansion of "false", and the macro definition was in a syst= em header. So far, so good. However, during normal operation, with the integrated preprocessor, when a warning would be emitted in a system header, that get_location_for_expr_unwinding_for_system_header function added by the com= mit you were asking about, https://github.com/gcc-mirror/gcc/blob/releases/gcc-10.2.0/gcc/cp/call.c#L7= 146, would change the warning location to that of the macro expansion point, if = the warning location was actually inside a macro definition from a system heade= r. Such macro unwinding is not possible when the preprocessor is invoked separately, as this information is missing in the -E output. A non-system-header effect of this can be seen in this test: test.h: #define FALSE false test.cc: #include "test.h" void *p =3D FALSE; g++ -std=3Dc++03 -c test.cc: In file included from test.cc:1: test.h:1:15: warning: converting =E2=80=98false=E2=80=99 to pointer type = =E2=80=98void*=E2=80=99 [-Wconversion-null] 1 | #define FALSE false | ^~~~~ test.cc:2:11: note: in expansion of macro =E2=80=98FALSE=E2=80=99 2 | void *p =3D FALSE; | ^~~~~ g++ -std=3Dc++03 -c test.cc -save-temps test.cc:2:11: warning: converting =E2=80=98false=E2=80=99 to pointer type = =E2=80=98void*=E2=80=99 [-Wconversion-null] 2 | void *p =3D FALSE; | ^~~~~ The addition of -save-temps causes the "note: in expansion of macro =E2=80= =98FALSE=E2=80=99" to go missing, because the information needed to produce that note is gone by = the time the warning is emitted: the macro expansion tracking is only available= at preprocessing time. It was that macro expansion tracking functionality that= GCC needs to determine that really, the warning should be treated as *not* comi= ng from a system header, even though it really was. In short: I think there is no lingering bug here, this is just an unfortuna= te result of the current design. However, if you disagree, if you think the ma= cro expansion tracking state should be included somehow in the preprocessor out= put so that the compiler always has access to it, I can report that as a new bu= g if you like.=