public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning @ 2021-03-25 11:46 acoplan at gcc dot gnu.org 2021-03-25 12:28 ` [Bug c/99768] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: acoplan at gcc dot gnu.org @ 2021-03-25 11:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768 Bug ID: 99768 Summary: [11 Regression] Bogus -Wuninitialized diagnostic with type punning Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- For the following code (which has a strict aliasing violation): float foo(unsigned v) { unsigned tmp = v; float *f = (float *)(&tmp); return *f; } at -O2 -Wall we warn that tmp is used uninitialized: test.c: In function ‘foo’: test.c:5:12: warning: ‘tmp’ is used uninitialized [-Wuninitialized] 5 | return *f; | ^~ test.c:3:14: note: ‘tmp’ declared here 3 | unsigned tmp = v; | ^~~ but this is clearly bogus. Not sure if this is strictly considered a bug given the strict aliasing problem, but thought it might be worth checking in any case. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/99768] [11 Regression] Bogus -Wuninitialized diagnostic with type punning 2021-03-25 11:46 [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning acoplan at gcc dot gnu.org @ 2021-03-25 12:28 ` rguenth at gcc dot gnu.org 2021-03-25 16:07 ` [Bug middle-end/99768] " msebor at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2021-03-25 12:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.0 Blocks| |24639 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the warning is correct - there is no valid initialization of a float entity in 'tmp' (in fact GCC removed the initialization from 'v'). It might be misleading but then what do you expect with invalid code? We could, in theory, do another walk to find an initialization with strict aliasing disabled and if we then find a candidate note that there are possible initializations (we won't be able to prove they are definite inits) but a violation of strict-aliasing might hide them. OTOH this would pop up a lot and likely confuse people to use -fno-strict-aliasing to simply hide the warning but not fix the missing initialization. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639 [Bug 24639] [meta-bug] bug to track all Wuninitialized issues ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/99768] [11 Regression] Bogus -Wuninitialized diagnostic with type punning 2021-03-25 11:46 [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning acoplan at gcc dot gnu.org 2021-03-25 12:28 ` [Bug c/99768] " rguenth at gcc dot gnu.org @ 2021-03-25 16:07 ` msebor at gcc dot gnu.org 2021-04-08 13:13 ` [Bug middle-end/99768] Unhelpful " rguenth at gcc dot gnu.org 2023-07-03 16:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: msebor at gcc dot gnu.org @ 2021-03-25 16:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-03-25 Status|UNCONFIRMED |NEW Component|c |middle-end Ever confirmed|0 |1 CC| |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The -Wuninitialized was introduced in g:b825a22890740f341eae566af27e18e528cd29a7. I don't think I meant for this to be diagnosed so I suspect it's a bug in the new code. I see no basis in the IL (below) to issue the warning. GCC should issue -Wstrict-aliasing instead (it does but only at level 2). float foo (unsigned int v) { float * f; unsigned int tmp; float _5; <bb 2> : tmp = v_2(D); f_4 = &tmp; _5 = *f_4; << -Wuninitialized tmp ={v} {CLOBBER}; return _5; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/99768] Unhelpful -Wuninitialized diagnostic with type punning 2021-03-25 11:46 [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning acoplan at gcc dot gnu.org 2021-03-25 12:28 ` [Bug c/99768] " rguenth at gcc dot gnu.org 2021-03-25 16:07 ` [Bug middle-end/99768] " msebor at gcc dot gnu.org @ 2021-04-08 13:13 ` rguenth at gcc dot gnu.org 2023-07-03 16:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2021-04-08 13:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Target Milestone|11.0 |--- Summary|[11 Regression] Bogus |Unhelpful -Wuninitialized |-Wuninitialized diagnostic |diagnostic with type |with type punning |punning --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Let's keep it open as enhancement since the diagnostic isn't very helpful to the user - but it is still technically correct since GCC will simply remove the initialization as it has no valid use. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/99768] Unhelpful -Wuninitialized diagnostic with type punning 2021-03-25 11:46 [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning acoplan at gcc dot gnu.org ` (2 preceding siblings ...) 2021-04-08 13:13 ` [Bug middle-end/99768] Unhelpful " rguenth at gcc dot gnu.org @ 2023-07-03 16:04 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-07-03 16:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vanyacpp at gmail dot com --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 110534 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-03 16:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-03-25 11:46 [Bug c/99768] New: [11 Regression] Bogus -Wuninitialized diagnostic with type punning acoplan at gcc dot gnu.org 2021-03-25 12:28 ` [Bug c/99768] " rguenth at gcc dot gnu.org 2021-03-25 16:07 ` [Bug middle-end/99768] " msebor at gcc dot gnu.org 2021-04-08 13:13 ` [Bug middle-end/99768] Unhelpful " rguenth at gcc dot gnu.org 2023-07-03 16:04 ` pinskia 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).