public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amodra at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/102867] New: Waddress complaint in readelf.c
Date: Thu, 21 Oct 2021 04:53:23 +0000	[thread overview]
Message-ID: <bug-102867-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-10-21  4:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  4:53 amodra at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102867-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).