Bug 96368 - False negative with maybe-uninitialized with goto
Summary: False negative with maybe-uninitialized with goto
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 8.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2020-07-29 12:54 UTC by Salamandar
Modified: 2020-07-29 16:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
minimal code for missing maybe-uninitialized warning (187 bytes, text/plain)
2020-07-29 12:54 UTC, Salamandar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Salamandar 2020-07-29 12:54:12 UTC
Created attachment 48951 [details]
minimal code for missing maybe-uninitialized warning

There are cases where GCC should warn about maybe-uninitialized variables but doesn't.

In the attached minimal code, the `goto` may prevent the eth.pktio to be initialized, but GCC doesn't warn about it.

Weirdly enough, if the pktio_read() call is uncommented, GCC warns that eth.pktio may be uninitialized.

Of course the fix is to initialize eth.pktio before the goto.
Comment 1 Manuel López-Ibáñez 2020-07-29 15:58:29 UTC
I'm pretty sure this is PR18501. 

pktio_read() creates a PHI node and prevents CCP deleting the undefined value.

*** This bug has been marked as a duplicate of bug 18501 ***
Comment 2 Salamandar 2020-07-29 16:00:58 UTC
I just tried with GCC 9.3 and the bug is still present.

https://godbolt.org/z/TYarqe
Comment 3 Manuel López-Ibáñez 2020-07-29 16:15:00 UTC
(In reply to Salamandar from comment #2)
> I just tried with GCC 9.3 and the bug is still present.
> 
> https://godbolt.org/z/TYarqe

Yes, PR18501 is still open (and it won't be fixed anytime soon, it is too difficult).