This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Optimizer Bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Optimizer Bug
- From: "Robert M. Fleischman" <rmf at bcandid dot com>
- Date: Fri, 3 Mar 2000 12:19:24 -0500
Turning on optimization causes a warning. I'm very worried that this
causes INCORRECT code to be generated by the latest gcc.
Example Code:
class X {
public:
X() {}
~X() {
int y = 0;
while (y) { }
}
};
int *foo()
{
X x;
return new int(3);
}
int main()
{
delete foo();
return 0;
}
Optimization causes BOGUS warning:
% g++ -O -c -Wall -Werror foo.C
cc1plus: warnings being treated as errors
foo.C: In function `int * foo()':
foo.C:15: warning: control reaches end of non-void function `foo()'
%
WITHOUT Optimization it is silent:
% g++ -c -Wall -Werror foo.C
%
Version of gcc:
% g++ -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
---------
Clearly, contol CAN NOT reach the end of foo() without a valid return!
I suspect something in the inline'd destructor under optimization is
causing something very bad to happen!
-Rob