public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "eggert at gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/63943] New: -Wmaybe-uninitialized pragma mishandled in inlined function
Date: Tue, 18 Nov 2014 23:01:00 -0000	[thread overview]
Message-ID: <bug-63943-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 63943
           Summary: -Wmaybe-uninitialized pragma mishandled in inlined
                    function
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at gnu dot org

Created attachment 34031
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34031&action=edit
Program with -Wmaybe-uninitialized problem

Compile the attached program t.c with "gcc -Wmaybe-uninitialized -O2 -c t.c" on
x86-64 with GCC 4.9.2, and the output will be:

t.c: In function 'main':
t.c:17:3: warning: '*((void *)&v+4)' may be used uninitialized in this function
[-Wmaybe-uninitialized]
   return argc < 1 ? !argv : dereference (v + 1);
   ^

'#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"' is in effect when the
possibly-uninitialized variable is used, but this use is in a function that GCC
inlined, and GCC is incorrectly warning based on the pragma setting in the
calling function, not based on the pragma setting where the dereferencing
actually occurs.

The problem does not occur with GCC 4.8.3 so this appears to be a regression.

The problem also goes away if I add '__attribute__((noinline))' to the
'dereference' function, so this appears to be related to inlining.

I ran into this problem while thinking about enabling -Werror when compiling
glibc; my first cut at this ran into the above problem.


             reply	other threads:[~2014-11-18 23:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 23:01 eggert at gnu dot org [this message]
2014-11-19 15:16 ` [Bug middle-end/63943] wrong location for -Wmaybe-uninitialized " manu at gcc dot gnu.org
2021-03-31 16:15 ` msebor at gcc dot gnu.org
2021-03-31 17:56 ` manu at gcc dot gnu.org
2021-03-31 20:36 ` egallager at gcc dot gnu.org
2021-04-15 16:49 ` 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-63943-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).