public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102996] New: No warning on use dereferencing of uninitialized point in an array
@ 2021-10-29  7:34 eyalroz1 at gmx dot com
  2021-10-29  9:49 ` [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eyalroz1 at gmx dot com @ 2021-10-29  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102996
           Summary: No warning on use dereferencing of uninitialized point
                    in an array
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eyalroz1 at gmx dot com
  Target Milestone: ---

Consider the following two functions:

void foo() {
    int *as[2];
    *(as[0])=1;
}

void bar() {
    int i = 0;
    int *as[2];
    for(i=0;i<1;i++)
    {
        *(as[i])=i;
    }
}


When compiling these with -Wall, we get warnings about the uninitialized use of
as in the first function, but not in the second one.

GodBolt: https://godbolt.org/z/Ta9fWYWs6
Inspired by this StackOverflow question:
https://stackoverflow.com/q/69764896/1593077

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

* [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop
  2021-10-29  7:34 [Bug c/102996] New: No warning on use dereferencing of uninitialized point in an array eyalroz1 at gmx dot com
@ 2021-10-29  9:49 ` rguenth at gcc dot gnu.org
  2021-10-29 10:10 ` eyalroz1 at gmx dot com
  2021-10-29 15:03 ` [Bug tree-optimization/102996] " msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-29  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-10-29
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |24639
           Keywords|                            |diagnostic

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The foo form is handled by the early uninit pass but the bar form is optimized
away as dead before we get to do a late warning.


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] 4+ messages in thread

* [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop
  2021-10-29  7:34 [Bug c/102996] New: No warning on use dereferencing of uninitialized point in an array eyalroz1 at gmx dot com
  2021-10-29  9:49 ` [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop rguenth at gcc dot gnu.org
@ 2021-10-29 10:10 ` eyalroz1 at gmx dot com
  2021-10-29 15:03 ` [Bug tree-optimization/102996] " msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: eyalroz1 at gmx dot com @ 2021-10-29 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Eyal Rozenberg <eyalroz1 at gmx dot com> ---
(In reply to Richard Biener from comment #1)
> The foo form is handled by the early uninit pass

Since _none_ of `as` is initialized, one could argue that an early uninit pass
could catch that as well.

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

* [Bug tree-optimization/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop
  2021-10-29  7:34 [Bug c/102996] New: No warning on use dereferencing of uninitialized point in an array eyalroz1 at gmx dot com
  2021-10-29  9:49 ` [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop rguenth at gcc dot gnu.org
  2021-10-29 10:10 ` eyalroz1 at gmx dot com
@ 2021-10-29 15:03 ` msebor at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-29 15:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
          Component|c                           |tree-optimization

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The early uninit pass deliberately defers the conditional cases to the late
pass to avoid false positives.  It only handles straightforward unconditionally
uninitialized reads.  It could probably do better.

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

end of thread, other threads:[~2021-10-29 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29  7:34 [Bug c/102996] New: No warning on use dereferencing of uninitialized point in an array eyalroz1 at gmx dot com
2021-10-29  9:49 ` [Bug c/102996] No warning on dereferencing of uninitialized pointer in an array, in a loop rguenth at gcc dot gnu.org
2021-10-29 10:10 ` eyalroz1 at gmx dot com
2021-10-29 15:03 ` [Bug tree-optimization/102996] " msebor 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).