https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105628
Bug ID: 105628
Summary: False positive with -Waddress
Product: gcc
Version: 12.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jochen447 at concept dot de
Target Milestone: ---
Created attachment 52986
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52986&action=edit
minified example program to show the false positive
Option -Wall also enables -Waddress, which causes a lot of false positives like
shown in my attached example problem (minimized and anonymized real world
example):
waddress.c: In function ‘comp_has_ExtraPtr’:
waddress.c:44:29: warning: the comparison will always evaluate as ‘true’ for
the pointer operand in ‘(struct Extra **)&comp->pin + 4’ must not be NULL
[-Waddress]
44 | return ExtraPtrOf(comp) ? 1 : 0;
| ^
It only seems to be emitted when using the ?-operator.
# gcc -v
...
gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)
# uname -a
Linux fedora 5.17.6-300.fc36.x86_64 #1 SMP PREEMPT Mon May 9 15:47:11 UTC 2022
x86_64 x86_64 x86_64 GNU/Linux