How can I mitigate the impact of the Intel jcc erratum on gcc?

By compiler: GCC: -Wa,-mbranches-within-32B-boundaries clang (10+): -mbranches-within-32B-boundaries compiler option directly, not -Wa. MSVC: /QIntel-jcc-erratum See Intel JCC Erratum – what is the effect of prefixes used for mitigation? ICC: TODO, look for docs. The GNU toolchain does mitigation in the assembler, with as -mbranches-within-32B-boundaries, which enables (GAS manual: x86 options): -malign-branch-boundary=32 (care about 32-byte boundaries). … Read more

Is there a compiler bug exposed by my implementation of an is_complete type trait?

The problem appears to be with the definition of void_t. Defining it as template<typename… Ts> struct make_void { typedef void type;}; template<typename… Ts> using void_t = typename make_void<Ts…>::type; instead yields the correct result (10) on both compilers (Demo). I believe this is the same issue noted in section 2.3 of N3911, the paper proposing void_t, … Read more

GCC left shift overflow

Short answer: the Intel processor masks the shift count to 5 bits (maximum 31). In other words, the shift actually performed is 32 & 31, which is 0 (no change). The same result appears using gcc on a Linux 32-bit PC. I assembled a shorter version of this program because I was puzzled by why … Read more

How to include omp.h in OS X?

This command can help you brew install libomp brew info libomp libomp: stable 6.0.1 (bottled) LLVM’s OpenMP runtime library /usr/local/Cellar/libomp/6.0.1 (12 files, 1.2MB) * Poured from bottle on 2018-11-20 at 16:12:22 From: ==> Dependencies Build: cmake ✘ ==> Requirements Required: macOS >= 10.10 ✔ ==> Caveats On Apple Clang, you need to add … Read more

GCC: Array type has incomplete element type

It’s the array that’s causing trouble in: void print_graph(g_node graph_node[], double weight[][], int nodes); The second and subsequent dimensions must be given: void print_graph(g_node graph_node[], double weight[][32], int nodes); Or you can just give a pointer to pointer: void print_graph(g_node graph_node[], double **weight, int nodes); However, although they look similar, those are very different internally. … Read more