Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > run incorrecly using -O?

Reply
Thread Tools

run incorrecly using -O?

 
 
Onix
Guest
Posts: n/a
 
      04-10-2008
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?
 
Reply With Quote
 
 
 
 
utab
Guest
Posts: n/a
 
      04-10-2008
On Apr 10, 8:45 pm, Onix <(E-Mail Removed)> wrote:
> 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,
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      04-11-2008
Victor Bazarov wrote:
> Onix wrote:
>> 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?

>
> 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).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts run using load in "for" loop run out of order Fa Sidd Ruby 12 01-26-2008 12:06 AM
What is the difference of modelsim command run -continue and run -all rxjwg98@gmail.com VHDL 2 09-05-2006 02:14 PM
Can't Run 'RUN' Windows XP Home Luke O'Malley Computer Support 2 09-01-2005 11:38 PM
can run javascript can't run vbscript - WHY duncan ASP .Net 2 10-27-2004 09:31 AM
Anybody remember, Run Buddy Run and Second Hundred Years? Tom McCafferty DVD Video 5 10-02-2004 09:15 PM



Advertisments