[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 Jeffrey A. Law changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #10 from Jeffrey A. Law --- Per c#9.
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 Martin Liška changed: What|Removed |Added Keywords|needs-bisection | CC||marxin at gcc dot gnu.org --- Comment #9 from Martin Liška --- It has gone on trunk with r260350: SVN revision: 260350 Author: marxin Radically simplify emission of balanced tree for switch statements. 2018-05-18 Martin Liska * passes.def: Add pass_lower_switch and pass_lower_switch_O0. * tree-pass.h (make_pass_lower_switch_O0): New function. * tree-switch-conversion.c (node_has_low_bound): Remove. (node_has_high_bound): Likewise. (node_is_bounded): Likewise. (class pass_lower_switch): Make it a template type and create two instances. (pass_lower_switch::execute): Add template argument. (make_pass_lower_switch): New function. (make_pass_lower_switch_O0): New function. (do_jump_if_equal): Remove. (emit_case_nodes): Simplify to just handle all 3 cases and leave all the hard work to tree optimization passes. 2018-05-18 Martin Liska * gcc.dg/tree-ssa/vrp104.c: Adjust dump file that is scanned. * gcc.dg/tree-prof/update-loopch.c: Likewise.
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 --- Comment #8 from Jeffrey A. Law --- Understood on your hardware limitations. You could certainly do bisection work on the compile farm. Again, thanks for your work on cleaning up some of this old stuff.
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 --- Comment #7 from Eric Gallager --- (In reply to Jeffrey A. Law from comment #6) > Eric. Thanks for the BZ maintenance. It's definitely appreciated. > > For bugs like this (very sensitive to unrelated code generator changes) it > is often worth the time to bisect to what change fixed the bug. That helps > us identify something that just went latent vs something that actually got > fixed. I wish I could bisect but I don't exactly have the computing resources on this old laptop for the whole bisection process; is that something I could do on the gcc compile farm? > > I happened to have been looking at this yesterday so I had a bit of state. > I'm pretty sure this just went latent. Martin L's recent changes to switch > handling result in dropping the switch into an if-else which we often > optimize/analyze better. > > A slight tweak to keep Martin L's changes from firing brings the warning > back. > > > #include > #include > > static int mk (int **a, int **b, int **c) { > if (!(*a = malloc (sizeof (int goto a_err; > if (!(*b = malloc (sizeof (int goto b_err; > if (!(*c = malloc (sizeof (int goto c_err; > > return 1; c_err: > free (*b); b_err: > free (*a); a_err: > return 0; > } > > static void fin (int *a, int *b, int *c) { > free (c); > free (b); > free (a); > } > > int main (void) { > int *a, *b, *c, x, flag = mk (&a, &b, &c); > while ((x = getchar ()) != -1) { > if (flag) switch (x) { > case 0: > break; > case 0xdeadbeef: > goto retm; > default: > goto retn; > } else if (x) goto retn; > } > retn: > if (flag) fin (a, b, c); > return 0; > retm: > if (flag) fin (a, b, c); > return 0; > } > ~ Yup, confirmed that this brings the warning back.
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 Jeffrey A. Law changed: What|Removed |Added Status|RESOLVED|NEW Last reconfirmed||2017-10-01 CC||law at redhat dot com Resolution|WORKSFORME |--- Ever confirmed|0 |1 --- Comment #6 from Jeffrey A. Law --- Eric. Thanks for the BZ maintenance. It's definitely appreciated. For bugs like this (very sensitive to unrelated code generator changes) it is often worth the time to bisect to what change fixed the bug. That helps us identify something that just went latent vs something that actually got fixed. I happened to have been looking at this yesterday so I had a bit of state. I'm pretty sure this just went latent. Martin L's recent changes to switch handling result in dropping the switch into an if-else which we often optimize/analyze better. A slight tweak to keep Martin L's changes from firing brings the warning back. #include #include static int mk (int **a, int **b, int **c) { if (!(*a = malloc (sizeof (int goto a_err; if (!(*b = malloc (sizeof (int goto b_err; if (!(*c = malloc (sizeof (int goto c_err; return 1; c_err: free (*b); b_err: free (*a); a_err: return 0; } static void fin (int *a, int *b, int *c) { free (c); free (b); free (a); } int main (void) { int *a, *b, *c, x, flag = mk (&a, &b, &c); while ((x = getchar ()) != -1) { if (flag) switch (x) { case 0: break; case 0xdeadbeef: goto retm; default: goto retn; } else if (x) goto retn; } retn: if (flag) fin (a, b, c); return 0; retm: if (flag) fin (a, b, c); return 0; } ~
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 Eric Gallager changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |WORKSFORME --- Comment #5 from Eric Gallager --- I can't reproduce the bug with gcc trunk; neither the original nor the preprocessed source give me any warnings. Feel free to reopen if it still happens for you.
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 --- Comment #4 from Casper Ti. Vector --- (In reply to Manuel López-Ibáñez from comment #3) > This is just too weird code for GCC to analyze correctly at -O2. It doesn't > warn at -O3 (with 5.4.0 20160609) The coding pattern is quite common though. Nevertheless, if that only makes trouble for `-Wmaybe-uninitialized' (and not the generated code), it is somehow understandable. Thanks anyway :)
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 Manuel López-Ibáñez changed: What|Removed |Added CC||manu at gcc dot gnu.org --- Comment #3 from Manuel López-Ibáñez --- This is just too weird code for GCC to analyze correctly at -O2. It doesn't warn at -O3 (with 5.4.0 20160609)
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 --- Comment #2 from Casper Ti. Vector --- Created attachment 40856 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40856&action=edit Output of `sed '/^#/d; /^[ \t]*$/d' < gcc_bug.i'
[Bug middle-end/79768] `-Wmaybe-uninitialized' false positive with optimisation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768 --- Comment #1 from Casper Ti. Vector --- Created attachment 40855 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40855&action=edit Output of `gcc -v -save-temps -Wall -O2 -c gcc_bug.c -o gcc_bug.o'