public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og
       [not found] <bug-78394-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-01 20:42 ` msebor at gcc dot gnu.org
  2021-04-02  8:02 ` linux at carewolf dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-01 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2017-07-20 00:00:00         |2021-4-1
      Known to fail|                            |10.2.0, 11.0, 6.3.0, 7.0.1,
                   |                            |8.3.0, 9.3.0
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11.  Both instances of the warning go back as far as
support  for -Og so it's not a regression.

With my patched GCC the output for just the first function is:

pr78394.C: In function ‘float foo()’:
pr78394.C:19:17: warning: ‘vy’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   19 |     return vx + vy;
      |                 ^~
pr78394.C:13:15: note: used when ‘(a <= i)’
   13 |     float vx, vy;
      |               ^~
pr78394.C:13:15: note: ‘vy’ was declared here
pr78394.C:19:17: warning: ‘vx’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   19 |     return vx + vy;
      |                 ^~
pr78394.C:13:11: note: used when ‘(a <= i)’
   13 |     float vx, vy;
      |           ^~
pr78394.C:13:11: note: ‘vx’ was declared here


The dump the warning sees is below as as noted the root cause is that the IL
satisfies the conditions under which it's designed to trigger.  So the only
ways to avoid it would seem to be to either a) extend the warning to figure out
that the condition it uses cannot happen (basically implement some of the
optimizations disabled at -Og) or b) turn off -Wmaybe-uninitialized at -Og
(i.e,. remove it from -Wall).  I'm not in favor of (a) but (b) makes sense to
me.  I'd like to try to improve it for GCC 12 so unless I fail at that I'm not
for disabling it at other optimization levels.

float foo ()
{
  int i;
  float vy;
  float vx;
  int a;
  float _6;
  float _8;

  <bb 2> [local count: 118111600]:
  # VUSE <.MEM_4(D)>
  a_5 = b;
  if (a_5 <= 3)
    goto <bb 3>; [50.00%]
  else
    goto <bb 8>; [50.00%]

  <bb 8> [local count: 59055800]:
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 59055800]:

  <bb 4> [local count: 118111600]:
  # a_1 = PHI <a_5(8), 4(3)>
  goto <bb 6>; [100.00%]

  <bb 5> [local count: 955630225]:
  _8 = (float) i_2;
  i_7 = i_2 + 1;

  <bb 6> [local count: 1073741824]:
  # i_2 = PHI <1(4), i_7(5)>
  # .MEM_3 = PHI <.MEM_4(D)(4), .MEM_3(5)>
  # vx_9 = PHI <vx_11(D)(4), _8(5)>
  # vy_10 = PHI <vy_12(D)(4), _8(5)>
  if (a_1 > i_2)
    goto <bb 5>; [89.00%]
  else
    goto <bb 7>; [11.00%]

  <bb 7> [local count: 118111600]:
  _6 = vx_9 + vy_10;
  # VUSE <.MEM_3>
  return _6;

}

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

* [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og
       [not found] <bug-78394-4@http.gcc.gnu.org/bugzilla/>
  2021-04-01 20:42 ` [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og msebor at gcc dot gnu.org
@ 2021-04-02  8:02 ` linux at carewolf dot com
  2021-06-01  9:21 ` marxin at gcc dot gnu.org
  2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: linux at carewolf dot com @ 2021-04-02  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Allan Jensen <linux at carewolf dot com> ---
Yes, if you can figure out exactly what optimization passes it needs, then we
could disable the warning when those passes are disabled.

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

* [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og
       [not found] <bug-78394-4@http.gcc.gnu.org/bugzilla/>
  2021-04-01 20:42 ` [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og msebor at gcc dot gnu.org
  2021-04-02  8:02 ` linux at carewolf dot com
@ 2021-06-01  9:21 ` marxin at gcc dot gnu.org
  2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-01  9:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78394
Bug 78394 depends on bug 100845, which changed state.

Bug 100845 Summary: [11/12 Regression] False positive for -Werror=maybe-uninitialized since r11-959-gb825a22890740f34
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100845

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

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

* [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og
       [not found] <bug-78394-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-06-01  9:21 ` marxin at gcc dot gnu.org
@ 2022-08-31 11:04 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-31 11:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78394
Bug 78394 depends on bug 65244, which changed state.

Bug 65244 Summary: Bogus -Wmaybe-uninitialized warning with posix_memalign() and -Og
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65244

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

end of thread, other threads:[~2022-08-31 11:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-78394-4@http.gcc.gnu.org/bugzilla/>
2021-04-01 20:42 ` [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og msebor at gcc dot gnu.org
2021-04-02  8:02 ` linux at carewolf dot com
2021-06-01  9:21 ` marxin at gcc dot gnu.org
2022-08-31 11:04 ` rguenth 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).