How can I prevent GCC from optimizing out a busy wait loop?

I developed this answer after following a link from dmckee’s answer, but it takes a different approach than his/her answer. Function Attributes documentation from GCC mentions: noinline This function attribute prevents a function from being considered for inlining. If the function does not have side-effects, there are optimizations other than inlining that causes function calls … Read more

What’s going on in __libc_start_main?

The first block, ending in “@plt”, is the procedure linkage table (https://stackoverflow.com/a/5469334/994153). The jmp *0x8049658 is an indirect branch instruction, so it actually is jumping to __libc_start_main wherever it actually ends up getting loaded in RAM at runtime. The real RAM address of __libc_start_main is found in the DYNAMIC RELOCATION RECORDS table, which is created … Read more

Explanation wanted: log10 faster than log and log2, but only with O2 and greater [closed]

This is going to depend on the implementation of the log() functions in the C library, compiler version, hardware architecture, and so on. Anyway, below I’m using GCC 4.4 on x86-64 with glibc 2.11. Changing the example so that I add a line cout << “sum=” << sum << endl; which prevents the compiler from … Read more

GCC(/Clang): Merging functions with identical instructions (COMDAT folding)

Neither GCC nor Clang is a linker, and ICF needs to be done by the linker, or at least with cooperation with the linker. Edit: They don’t do ICF, so yes, distinct instantiations produce distinct code. The GNU gold linker supports ICF with the –icf option, which needs the GCC option -ffunction-sections to be used. … Read more

What do the numbers mean in the preprocessed .i files when compiling C with gcc?

The numbers following the filename are flags: 1: This indicates the start of a new file. 2: This indicates returning to a file (after having included another file). 3: This indicates that the following text comes from a system header file, so certain warnings should be suppressed. 4: This indicates that the following text should … Read more

Difference between regex_match and regex_search?

Assuming that C++ and Boost Regex have a similar structure and functionality, the difference between regex_match and regex_search is explained here: The regex_match() algorithm will only report success if the regex matches the whole input, from beginning to end. If the regex matches only a part of the input, regex_match() will return false. If you … Read more

why there are two virtual destructor in the virtual table and where is address of the non-virtual function (gcc4.6.3)

Non-virtual member function The address of the non-virtual member function, well you said it, it’s not virtual which means it doesn’t need to be in the virtual table. Why? Well it doesn’t depend on the runtime type of the object, only the static type meaning the compiler can figure out at compile time which function … Read more

No realize class procedure defined

I suspected the problem could be on the libXt since the XtRealizeWidget symbol is defined in that library. I looked at it using nm but all seemed well: $ nm -D /usr/lib/libXt.so |grep XtRealizeWidget 02b39870 T XtRealizeWidget The “T” means the symbol is in the text (code) section of the object files that compose the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)