Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
286 views

Improve g++ compiler flags for debug and release

I am making a game in c++ with sdl2, and I am currently compiling the program with g++ using the following flags: DEBUG_FLAGS = -g -Og -DDEBUG RELEASE_FLAGS = -O3 -DNDEBUG -mwindows -s I want the ...
Invader88's user avatar
0 votes
0 answers
58 views

Function inlined in the header increments the wrong attribute: subtle bug

The setup (source files are listed at the bottom). There is a Counters class with 2 counter members and 2 methods to increment them and a 3rd extra #ifndef NDEBUG-guarded "debug" counter and ...
rtviii's user avatar
  • 897
0 votes
0 answers
232 views

In GCC, how to convert a predefined optimization level into a list of finer grained optimization flags?

I'm measuring how optimization flag number affects the coverage of GCC when it is compiling some test cases. I know GCC has predefined optimization levels, such as -O1 and -O2. I also know how to ...
潇洒张's user avatar
  • 339
2 votes
1 answer
2k views

Recommendation for nvfortran compiler useful flags

I use gfortran for years but quite new to nvfortran. I would like to ask if anyone can give me recommendation for nvfortran compiler useful flags for both debug and build modes? what I know for debug ...
imronuke's user avatar
0 votes
0 answers
203 views

Force gcc to put all code between prologue and epilogue

When I create very simple C function, something along these lines void foo(int a) { for (int i=0; i < a; i++) { if (i < 4) { do_something() } else { do_something_else() ...
tach's user avatar
  • 673
3 votes
1 answer
1k views

what are the compilation flags that are activated by using O3

we are in the process of changing the intel compiler version from v14 to v18 in our systems and by running the tests, we have noticed that O3 in some cases produces incorrect results whereas the same ...
user2348209's user avatar
0 votes
1 answer
86 views

GCC flag to ignore instruction dependencies

I am trying to decompile a piece of code and apparently gcc prefers less complicated instructions over the more complex ones. After reading this answer I suspect it's because gcc is trying to reduce ...
Bat's user avatar
  • 833
0 votes
2 answers
622 views

g++ -fno-enforce-eh-specs - why/how does this violate the C++ standard?

From man gcc: -fno-enforce-eh-specs Don't generate code to check for violation of exception specifications at run time. This option violates the C++ standard, but may be useful ...
einpoklum's user avatar
  • 130k
23 votes
1 answer
11k views

What flags does -march=native activate with Clang?

With GCC one is able to print out the specific flags that -march=native triggers. Is it possible to have Clang print similar information?
Christopher Johnson's user avatar
2 votes
3 answers
257 views

How can I compile this very big, but boring C source?

The central function in my code looks like this (everything else is vanilla input and output): const int n = 40000; double * foo (double const * const x) { double * y = malloc (n*sizeof(double));...
Wrzlprmft's user avatar
  • 4,375
5 votes
3 answers
3k views

Is it realistic to use -O3 or -Ofast to compile your benchmark code or will it remove code?

When compiling the benchmark code below with -O3 I was impressed by the difference it made in latency so i began to wonder whether the compiler is not "cheating" by removing code somehow. Is there a ...
LatencyGuy's user avatar
0 votes
1 answer
622 views

Which gcc O2 flag may cause failure in fp calculation?

I compiled paranoia floating point test suit on a pc386 system using GCC O2 level of optimization and got several failures but then compiled it without optimization with the same GCC and got correct ...
Ardalan Pouyabahar's user avatar
9 votes
3 answers
14k views

What is the proper architecture-specific options (-m) for Sandy Bridge based Pentium?

I'm trying to figure out how to set -march option properly to see how much performance difference between the option enabled and disabled can occur on my PC with gcc 4.7.2. Before trying compiling, ...
nekomachi-touge's user avatar
10 votes
1 answer
4k views

When to use certain optimizations such as -fwhole-program and -fprofile-generate with several shared libraries

Probably a simple answer; I get quite confused with the language used in the GCC documentation for some of these flags! Anyway, I have three libraries and a program which uses all these three. I ...
James's user avatar
  • 183
1 vote
1 answer
366 views

compile with no optimization? as safe as possible?

I have some code acting very weird. Weird enough people accused my output isn't really happening (i wish, that would make my life easier). The code works fine in windows (ms vc++, gcc) but fails on ...
user avatar
12 votes
2 answers
3k views

How much should I optimize?

In regards to optimizations done by the compiler (GCC), what is the standard practice? What does each option (-O, -O1, -O2, -O3, -Os, -s, -fexpensive-optimizations) do differently, and how do I decide ...
user avatar
2 votes
2 answers
371 views

Compiler flags change code behavior (O2, Ox)

The following code works as expected with flags Od, O1 but fails with O2, Ox. Any ideas why? edit: by "fails" I mean that the function does nothing, and seems to just return. void thread_sleep() { ...
aCuria's user avatar
  • 7,145
208 votes
6 answers
131k views

How to see which flags -march=native will activate?

I'm compiling my C++ app using GCC 4.3. Instead of manually selecting the optimization flags I'm using -march=native, which in theory should add all optimization flags applicable to the hardware I'm ...
vartec's user avatar
  • 134k