public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103089] New: -Wmaybe-uninitialized -O2 false positive
@ 2021-11-04 20:48 xantares09 at hotmail dot com
  2021-11-04 20:54 ` [Bug tree-optimization/103089] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: xantares09 at hotmail dot com @ 2021-11-04 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103089
           Summary: -Wmaybe-uninitialized -O2 false positive
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xantares09 at hotmail dot com
  Target Milestone: ---

Created attachment 51736
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51736&action=edit
minimal reproducer

on this example gcc 11.2, 11.1 gives a false positive for -Wmaybe-uninitialized
(at O2 only)


$ gcc -c -O2 -Wmaybe-uninitialized ks.c
ks.c: In function ‘DurbinMatrix’:
ks.c:21:18: warning: ‘*H_67 + _146’ may be used uninitialized
[-Wmaybe-uninitialized]
   21 |   H[(m - 1) * m] += (2 * h - 1 > 0 ? pow (2 * h - 1, (double) m) : 0);
      |                  ^~
ks.c:21:18: warning: ‘*H_67 + _146’ may be used uninitialized
[-Wmaybe-uninitialized]


we can see the whole H array is initialized because H[i * m + j] covers the
whole (0, m*m( range:

H = (double *) malloc ((m * m) * sizeof (double));
  for (i = 0; i < m; i++)
    for (j = 0; j < m; j++)
      if (i - j + 1 < 0)
        H[i * m + j] = 0;
      else
        H[i * m + j] = 1;

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

* [Bug tree-optimization/103089] -Wmaybe-uninitialized -O2 false positive
  2021-11-04 20:48 [Bug c/103089] New: -Wmaybe-uninitialized -O2 false positive xantares09 at hotmail dot com
@ 2021-11-04 20:54 ` pinskia at gcc dot gnu.org
  2021-11-04 21:04 ` xantares09 at hotmail dot com
  2021-11-04 21:16 ` xantares09 at hotmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-04 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
If I add:

  if (n <= 0 || m <= 0) __builtin_unreachable();
before the malloc, I get no warning.
I think the warning is correct if either n or m is negative.

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

* [Bug tree-optimization/103089] -Wmaybe-uninitialized -O2 false positive
  2021-11-04 20:48 [Bug c/103089] New: -Wmaybe-uninitialized -O2 false positive xantares09 at hotmail dot com
  2021-11-04 20:54 ` [Bug tree-optimization/103089] " pinskia at gcc dot gnu.org
@ 2021-11-04 21:04 ` xantares09 at hotmail dot com
  2021-11-04 21:16 ` xantares09 at hotmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: xantares09 at hotmail dot com @ 2021-11-04 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from xantares09 at hotmail dot com ---
indeed, I assumed both were positive, I guess there's no bug then

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

* [Bug tree-optimization/103089] -Wmaybe-uninitialized -O2 false positive
  2021-11-04 20:48 [Bug c/103089] New: -Wmaybe-uninitialized -O2 false positive xantares09 at hotmail dot com
  2021-11-04 20:54 ` [Bug tree-optimization/103089] " pinskia at gcc dot gnu.org
  2021-11-04 21:04 ` xantares09 at hotmail dot com
@ 2021-11-04 21:16 ` xantares09 at hotmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: xantares09 at hotmail dot com @ 2021-11-04 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

xantares09 at hotmail dot com changed:

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

--- Comment #3 from xantares09 at hotmail dot com ---
my bad, thanks for the reply

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

end of thread, other threads:[~2021-11-04 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 20:48 [Bug c/103089] New: -Wmaybe-uninitialized -O2 false positive xantares09 at hotmail dot com
2021-11-04 20:54 ` [Bug tree-optimization/103089] " pinskia at gcc dot gnu.org
2021-11-04 21:04 ` xantares09 at hotmail dot com
2021-11-04 21:16 ` xantares09 at hotmail dot com

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).