$ cat uninit.c 
static int blocksize = 4096; 
 
int bar (int); 
 
void foo (void) 
{ 
  int toread; 
  int bytes; 
  static char eof_reached = 0; 
 
  toread = blocksize; 
 
  while (toread != 0) 
    { 
      bytes = bar (toread); 
      if (bytes <= 0) 
        { 
          if (bytes < 0) 
            continue; 
          break; 
        } 
      toread -= bytes; 
    } 
 
  if (bytes == 0) 
    eof_reached = 1; 
} 
$ gcc -O2 -Wall -c uninit.c  
uninit.c: In function &#8216;foo&#8217;:  
uninit.c:25: warning: &#8216;bytes&#8217; is used uninitialized in this 
function  
  
This warning is wrong, since bytes is never used uninitialized as long as  
blocksize is non-zero.

-- 
           Summary: [4.0 regression] Wrong warning about uninitialized
                    variable
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schwab at suse dot de
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21548

Reply via email to