public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/82101] missed warning for uninitialized value on the loop entry edge
       [not found] <bug-82101-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-02 19:58 ` msebor at gcc dot gnu.org
  2021-04-02 20:19 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-02 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |msebor at gcc dot gnu.org
          Component|c++                         |middle-end

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 11 in C++ mode warns at all optimization levels:

$ cat pr82101.c && gcc  -Wall -xc++ pr82101.c
int main(){
    int k=k;
    for(int i = 0 ; i < 10 ; i ++){
        int t=t;
    }
    return 0;
}
pr82101.c: In function ‘int main()’:
pr82101.c:2:9: warning: ‘k’ is used uninitialized [-Wuninitialized]
    2 |     int k=k;
      |         ^
pr82101.c:2:9: note: ‘k’ was declared here
    2 |     int k=k;
      |         ^

According to my bisection, in C++ mode it started warning with r138835 (4.4.0
20080712), so I'm puzzled by Version being set to 7.1.1.

In C it never warned. I think C still doesn't complain about
self-initialization to accommodate the hack as a suppression mechanism for
-Wuninitialized/-Wmaybe-uinitialized.

So with that, I'm going to resolve this as fixed.

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

* [Bug middle-end/82101] missed warning for uninitialized value on the loop entry edge
       [not found] <bug-82101-4@http.gcc.gnu.org/bugzilla/>
  2021-04-02 19:58 ` [Bug middle-end/82101] missed warning for uninitialized value on the loop entry edge msebor at gcc dot gnu.org
@ 2021-04-02 20:19 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-02 20:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
      Known to fail|                            |10.2.0, 11.0, 7.3.0, 8.3.0,
                   |                            |9.2.0
   Last reconfirmed|2017-09-05 00:00:00         |2021-4-2
             Status|RESOLVED                    |NEW

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Let me take that back.  The complaint is about the missing warning for the
variable in the loop, not the one outside it, and presumably with -O1 or above.
 That's not quite clear from the description.

Here's a test case for the problem.  It's never been diagnosed:

$ cat pr82101.C && gcc -O1  -S -Wall pr82101.C
void f (int);

void g (void)
{
  for (int i = 0; i < 10; i++)
    {
      int t = t;   // -Wuninitialized  
      f (t);
    }
}

void h (void)
{
  for (int i = 0; i < 10; i++)
    {
      int t = t;   // missing warning 
    }
}

pr82101.C: In function ‘void g()’:
pr82101.C:8:9: warning: ‘t’ is used uninitialized [-Wuninitialized]
    8 |       f (t);
      |       ~~^~~
pr82101.C:7:11: note: ‘t’ was declared here
    7 |       int t = t;   // -Wuninitialized
      |           ^

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

end of thread, other threads:[~2021-04-02 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-82101-4@http.gcc.gnu.org/bugzilla/>
2021-04-02 19:58 ` [Bug middle-end/82101] missed warning for uninitialized value on the loop entry edge msebor at gcc dot gnu.org
2021-04-02 20:19 ` 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).