public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63943] New: -Wmaybe-uninitialized pragma mishandled in inlined function
@ 2014-11-18 23:01 eggert at gnu dot org
  2014-11-19 15:16 ` [Bug middle-end/63943] wrong location for -Wmaybe-uninitialized " manu at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: eggert at gnu dot org @ 2014-11-18 23:01 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2021-04-15 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 23:01 [Bug c/63943] New: -Wmaybe-uninitialized pragma mishandled in inlined function eggert at gnu dot org
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

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).