run incorrecly using -O?

O

Onix

I wrote a program and when compile it with g++ without optimized
option -O, the final program runs correctly, but if I compile it using
-O then the final program produced error.

Is there anything I need to aware when using -O?
 
U

utab

I wrote a program and when compile it with g++ without optimized
option -O, the final program runs correctly, but if I compile it using
-O then the final program produced error.

Is there anything I need to aware when using -O?

It is best if you paste some code to comment on?

Rgds,
 
R

red floyd

Victor said:
Your program most likely has undefined behaviour which changes if it
is compiled (optimized) a bit more than not at all. You need to aware
how to debug your program, and spend some time doing that.
That's not necessarily the case. I dealt with some (C -- not C++) code
where gcc did some overly aggressive optimizations that led to segfaults
and bus errors (granted, the code was using ugly constructs, but they
were well-defined).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top