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; ~~^~~~