This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Regression going from egcs-1.03 to egcs-19980803


Hi there,

there appears to be a regression going from egcs-1.03 to the latest
snapshot (egcs-19980803).
The problem is reproducible by means of a few lines of C (or C++:
it doesn't matter).
Everything is provided and explained below.
Keep up the good work

         Roberto

-------------------------------------------------------------------------------
The machine:

$ uname -a
Linux gandalf 2.0.32 #6 Sun Mar 22 22:05:21 CET 1998 i586 unknown

-------------------------------------------------------------------------------
egcs-19980803:

$ /u/local/bin/gcc -v
Reading specs from /u/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.53/specs
gcc version egcs-2.91.53 19980803 (gcc2 ss-980609 experimental)

-------------------------------------------------------------------------------
egcs-1.03:

$ gcc -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)

-------------------------------------------------------------------------------
The program (admittedly dumb -- a much reduced version of a perfectly
reasonable function in real code):

#include <assert.h>

int foo(int x)
{
  // Removing this assertion eliminates the warning.
  assert(x >= 0);
  // The '= 5' was added later to answer the question:
  // "could it be so broken to give the warning also for a variable
  // that is explicitely initialized?"
  // The answer is: yes.
  int i = 5;
  // Replacing x+3 by, e.g., x eliminates the warning.
  for (i = 0; i < x+3; ++i)
    // Replacing i > 3 by, e.g., i == 3 eliminates the warning.
    if (i > 3)
      return i;
  return -1;
}

-------------------------------------------------------------------------------
The result with egcs-19980803:

$ /u/local/bin/gcc -save-temps -O2 -Wall -c warnbug.cc
warnbug.cc: In function `int foo(int)':
warnbug.cc:11: warning: `int i' might be used uninitialized in this function
$

-------------------------------------------------------------------------------
The result with egcs-19980803:

$ gcc -save-temps -O2 -Wall -c warnbug.cc
$

-------------------------------------------------------------------------------
warnbug.ii:

# 1 "warnbug.cc"
# 1 "/usr/include/assert.h" 1 3
 

















 



# 32 "/usr/include/assert.h" 3



# 1 "/usr/include/features.h" 1 3
 





















 















































 













 





 



 







 
# 117 "/usr/include/features.h" 3


 









 



















































 








 












 

# 1 "/usr/include/sys/cdefs.h" 1 3
 




















# 1 "/usr/include/features.h" 1 3
 

















# 222 "/usr/include/features.h" 3

# 22 "/usr/include/sys/cdefs.h" 2 3


 







# 54 "/usr/include/sys/cdefs.h" 3


 







 



# 86 "/usr/include/sys/cdefs.h" 3



 








 







# 205 "/usr/include/features.h" 2 3



 

 








# 1 "/usr/include/gnu/stubs.h" 1 3
 





























# 219 "/usr/include/features.h" 2 3




# 35 "/usr/include/assert.h" 2 3


 




# 56 "/usr/include/assert.h" 3


extern "C" { 

 
extern void __assert_fail  (__const char *__assertion,
				__const char *__file,
				unsigned int __line,
				__const char *__function)  
     __attribute__ ((__noreturn__));

 
extern void __assert_perror_fail  (int __errnum,
				       __const char *__file,
				       unsigned int __line,
				       __const char *__function)  
     __attribute__ ((__noreturn__));

} 













 











# 1 "warnbug.cc" 2


int foo(int x)
{
   
  ((void) (( x >= 0 ) ? 0 :	(__assert_fail ("x >= 0" ,	"warnbug.cc", 6,
__PRETTY_FUNCTION__ ), 0))) ;
   
   
   
   
  int i = 5;
   
  for (i = 0; i < x+3; ++i)
     
    if (i > 3)
      return i;
  return -1;
}

-------------------------------------------------------------------------------

-- 
Roberto Bagnara
Department of Mathematics, University of Parma, Italy
http://www.di.unipi.it/~bagnara/bagnara.html
mailto:bagnara@di.unipi.it


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]