public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102867] New: Waddress complaint in readelf.c
@ 2021-10-21  4:53 amodra at gmail dot com
  2021-10-21  4:55 ` [Bug c/102867] " amodra at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: amodra at gmail dot com @ 2021-10-21  4:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102867

            Bug ID: 102867
           Summary: Waddress complaint in readelf.c
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amodra at gmail dot com
  Target Milestone: ---

Compiling the attached readelf.i with -Wall -Werror -O2 using today's gcc
mainline on x86_64-linux results in complaints like

/home/alan/src/binutils-gdb/binutils/readelf.c: In function ‘find_section’:
/home/alan/src/binutils-gdb/binutils/readelf.c:762:42: error: the comparison
will always evaluate as ‘true’ for the pointer operand in
‘filedata->section_headers + (sizetype)((long unsigned int)i * 80)’ must not be
NULL [-Werror=address]
  762 |     if (SECTION_NAME_VALID (filedata->section_headers + i)

The warning is true, but annoying when coming from a macro expansion
#define SECTION_NAME_VALID(X) \
  ((X) != NULL                                                          \
   && filedata->string_table != NULL                                    \
   && (X)->sh_name < filedata->string_table_length)

In current readelf.c it looks like it may be possible to remove "(X) != NULL"
from this macro, but that doesn't seem like a good solution.  Another macro
with similar complaints
#define SECTION_NAME_PRINT(X) \
  ((X) == NULL ? _("<none>")                                            \
   : filedata->string_table == NULL ? _("<no-strings>")                 \
   : (X)->sh_name >= filedata->string_table_length ? _("<corrupt>")     \
   : filedata->string_table + (X)->sh_name)
can be called with X NULL.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-19 16:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  4:53 [Bug c/102867] New: Waddress complaint in readelf.c amodra at gmail dot com
2021-10-21  4:55 ` [Bug c/102867] " amodra at gmail dot com
2021-10-21  5:07 ` [Bug c/102867] [12 Regression] " pinskia at gcc dot gnu.org
2021-10-21  6:32 ` rguenth at gcc dot gnu.org
2021-10-21  6:58 ` amodra at gmail dot com
2021-10-21 16:16 ` msebor at gcc dot gnu.org
2021-10-23 23:51 ` [Bug c/102867] [12 Regression] -Waddress from macro expansion " msebor at gcc dot gnu.org
2021-11-19 16:48 ` cvs-commit at gcc dot gnu.org
2021-11-19 16:50 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).