473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

run incorrecly using -O?

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?
Apr 10 '08 #1
5 1136
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.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 10 '08 #2
On Apr 10, 8:45 pm, Onix <onix.x...@gmail.comwrote:
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,
Apr 10 '08 #3
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).
Apr 11 '08 #4
red floyd wrote:
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).
Right. Compiler/optimizer defects can affect the outcome as well,
although they are *less likely*. First thing to check is the case
of uninitialised pointer. But this cannot be concluded with any
certainty without looking at the code.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 11 '08 #5
red floyd wrote:
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).
Right. Compiler/optimizer defects can affect the outcome as well,
although they are *less likely*. First thing to check is the case
of uninitialised pointer. But this cannot be concluded with any
certainty without looking at the code.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using...
1
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
17
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
8
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
14
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
12
by: Calum Grant | last post by:
In older C++ computer books, you'll often see using namespace std; even in my 1996 copy of Stroustrup. Nowadays, it seems to be considered better to qualify names to make it clearer what...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.