From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 16F363858C62; Sun, 25 Jun 2023 13:06:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16F363858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687698405; bh=k3Ji1oHzIq+RGtOHZliA+xjsLh5ABkykzL7v8ta0tjg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aYulPaCP47m7jAQpfPO6HRXlwctq26BQbo7JCC/YqwZGuNC/BNoQG5f4kvJ3l2nlB pk9LMuhjQKy0zm3ym+06pjRuw5ZMYd1rjCuvW6WTaIdTKHZSzB9fMkF6iyf4OJk3Cg db9KPZKcfns6uVc0zb5gzbNtP7s/hy5C1ckO7I10= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110402] Bogus -Waddress warning that pointer comparison is always true Date: Sun, 25 Jun 2023 13:06:44 +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: 13.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: keywords 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110402 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic --- Comment #2 from Andrew Pinski --- We warn about: ``` struct m { float *v; int t; }; _Bool chk1(struct m *m, int key) { return &m->v[key]; } ``` ``` : In function 'chk1': :4:5: warning: the comparison will always evaluate as 'true' for the pointer operand in 'm->v + (sizetype)((long unsigned int)key * 4)' must not= be NULL [-Waddress] 4 | return &m->v[key]; | ^~~~~~ ``` The reason why the others in your testcase is not being warned about is more about the shape of the ?: and/or the comma operator getting in the way of moving the implict `!=3D0` into the `?:`.=