public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98900] New: Wrong static analyses warning when optimisation is on
@ 2021-01-31 12:23 oleg.pekar.2017 at gmail dot com
  2021-01-31 21:32 ` [Bug middle-end/98900] misleading -Wuninitialized using a variable outside its lifetime with -O2 msebor at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: oleg.pekar.2017 at gmail dot com @ 2021-01-31 12:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98900
           Summary: Wrong static analyses warning when optimisation is on
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oleg.pekar.2017 at gmail dot com
  Target Milestone: ---

Created attachment 50095
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50095&action=edit
Preprocessor output for source file test1.c

gcc version: 8.3.1
system type: RedHat 8.1, Kernel 4.18.0-147.3.1.el8_1.x86_64

Problem: Wrong static analyses warning when optimisation is on.
Input source: attached test1.i
Description: in this code address of a variable local to a block is used
outside of the block. With no optimisation there's no warning while the code
still can cause a problem. But with optimisation static analyses provides a
confusing warning - it complains about a variable not used in the context of
the warning.

Command line with no optimisation: gcc -Wall -save-temps test1.c
Output: nothing

Command line with optimisation: gcc -Wall -save-temps -O2 test1.c
Output: 
test1.c: In function ‘main’:
test1.c:11:7: warning: ‘x’ is used uninitialized in this function
[-Wuninitialized]
     g = *p;
     ~~^~~~

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

end of thread, other threads:[~2022-02-08 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31 12:23 [Bug c/98900] New: Wrong static analyses warning when optimisation is on oleg.pekar.2017 at gmail dot com
2021-01-31 21:32 ` [Bug middle-end/98900] misleading -Wuninitialized using a variable outside its lifetime with -O2 msebor at gcc dot gnu.org
2021-01-31 22:00 ` msebor at gcc dot gnu.org
2022-02-08 23:13 ` 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).