From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62E743858014; Fri, 25 Feb 2022 17:50:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62E743858014 From: "charles.nicholson at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/104693] New: Can't disable "comparison between pointer and integer" Date: Fri, 25 Feb 2022 17:50:20 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: charles.nicholson 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 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, 25 Feb 2022 17:50:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104693 Bug ID: 104693 Summary: Can't disable "comparison between pointer and integer" Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: charles.nicholson at gmail dot com Target Milestone: --- The following code causes gcc to emit a warning that does not seem to have a diagnostic name, which makes it hard (impossible?) to disable: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #include #include bool foo(unsigned long not_a_pointer) { return not_a_pointer =3D=3D NULL; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D : In function 'foo': :5:24: warning: comparison between pointer and integer 5 | return not_a_pointer =3D=3D NULL; | ^~ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Godbolt link: https://gcc.godbolt.org/z/chcxYevvf I don't think anyone would argue that this is "good" (portable, defined, et= c) C code; it is vendor code that I'm stuck with. Additionally, on the architect= ure I'm targeting, the implementation does the right thing: the unsigned long is pointer-sized, and is compared against the NULL literal 0, which is used in this context as a sentinel value. The code should use the literal 0 instead= of NULL, but it does not. I have 3 suggestions, if they're helpful: 1. If this warning can be disabled, update the diagnostic message to include the name as a hint on how to disable it. 2. If this warning can not be disabled, consider giving it a formal diagnos= tic name and making it controllable via the standard methods (-Wno-, pragma, et= c) 3. If this is truly heinous / unsafe enough, promote it to an error. Thanks for all of your efforts on gcc! Best, Charles=