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]

Optimizer Bug



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

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