Why -O2, -O3 optimization is not the default? [closed] - c++

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
I couldn't find an answer to this one. Assuming optimization does not break the code, why is -O3 or -O2 optimization not the default in C/C++? Why should we explicitly pass this flag? I cannot think of any situation where you would want your code to be not optimized.
I really don't understand why is this question closed and how it's opinion based.

Increasing the level of optimization increases the compilation time because the compiler has to do more work to optimize your code. It also makes debugging more difficult.

Related

Why is following the standard considered to produce unreadable code or to be impossible? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I was reading this post: https://stackoverflow.com/questions/1025494/obfuscating-c-c-code
The question is:
What tools are available to obfuscate C/C++ code....
An answer which had a bounty awarded to it says:
Follow the Standard insanely.
That'll be enough :)
I don't understand why people say following the standard would produce unreadable code or is impossible. Can someone explain what people mean in that post ? I'm a beginner programmer (in C / C++)

Can gcc's -fprofile-generate generate poor code for certain workloads? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've recently started using the -fprofile-generate option with gcc.
Is it possible to "under-profile" or "over-profile", such that the generated information from profiling causes subpar performance? Namely:
Can not running profiling for long enough resulting in worse optimizations?
Can running profiling for too long result in worse optimizations?

Spotting compilation-time bottlenecks in order to compilation firewall efficiently [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have this big C++ boostified project that takes ages to build so i'm trying to set up compilation firewalls. Now I could sprinkle pimpls or pure interfaces following my intuition but that doesn't seem very efficient... usually if i wanted to optimize a piece of code, I would run it through a profiler to see the bottlenecks which leads me to the following question: how do I see where are the bottlenecks in my compilation time?
All answers including trying alternate compilers are welcomed since code is cross-platform (crosses fingers!)
Thanks,

is -Dfoobar the standard for adding definition to the compiler for all C++ compiler? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am wondering if -Dfoobar the standard way for adding definition to the compiler for all the C++ compiler.
-Dfoobar works for all the compilers that have ever been used to compile Firefox, which is good enough for me. The Microsoft compilers also accept /Dfoobar, of course.

Is relying on short-circuit evaluation good design? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Are there alternatives that would be more preferred?
Short-circuit evaluation is a crucial feature of most modern programming languages and there's no reason to avoid relying on it. Without it pointer-related tests would be (unnecessarily) much more complicated and less readable.
Of course it's good design, everyone knows to expect it and it beats using nested conditionals.