egcs-1.1.1, wrong warning with -O2
Volker Apelt
va@org.chemie.uni-frankfurt.de
Fri Mar 26 03:14:00 GMT 1999
// DEFECT REPORT FOR egcs-2.91.60 19981201 (egcs-1.1.1 release)
//
// egcs emits a wrong warning with -O2. This warning will not appeare
// without -O2.
//
//
// keywords: optimize, destructor, goto, delete [], wrong warning,
///////////////
// System: linux (Suse 6.0 release)
///////////////
// cmdline> gcc -V 2.91.60 -Wreturn-type -O2 -c -o bug.o bug.cc
// ...
// bug.cc: In function `bool make()':
// bug.cc:36: warning: control reaches end of non-void function `make()'
//
// line 36 is the last line in make()
// Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/specs
// gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
///////////////////////////////////////////////////////////////////
// class A: class with data and user defined destructor
class A {
public:
inline ~A(void){};
private:
int x;
};
// class B: class with pointer to user defined data
// and delete [] in user defined destructor
class B {
private:
A* x;
public:
// use(): noop, avoid warning about unused vars,
// not required for bug
inline void use(void)const{};
inline ~B(void){ delete [] x; };
};
///////////////////////////////
bool make( void )
{
B b; b.use();
goto error_recover;
return 0;
error_recover:
A a;
return 1;
}; // this was line 36 of the error message
---
Volker Apelt Group of Prof. Dr. Ch. Griesinger
Johann Wolfgang Goethe Universitaet
Frankfurt am Main (Germany)
va@krypton.org.chemie.uni-frankfurt.de
More information about the Gcc-bugs
mailing list