gcc and clang implicitly instantiate template arguments during operator overload resolution

The entire point of the matter is ADL kicking in: N3797 – [basic.lookup.argdep] When the postfix-expression in a function call (5.2.2) is an unqualified-id, other namespaces not considered during the usual unqualified lookup (3.4.1) may be searched, and in those namespaces, namespace-scope friend function or function template declarations (11.3) not otherwise visible may be found. … Read more

How is GCC’s __thread implemented?

Recent GCC, e.g. GCC 5 do support C11 and its thread_local (if compiling with e.g. gcc -std=c11). As FUZxxl commented, you could use (instead of C11 thread_local) the __thread qualifier supported by older GCC versions. Read about Thread Local Storage. pthread_getspecific is indeed quite slow (it is in the POSIX library, so is not provided … Read more

Install gcc on linux with no root privilege

If you want to install it as a local user GNU GSRC provides an easy way to do so Link: http://www.gnu.org/software/gsrc/ After configuration, simply specify the following commands: cd gsrc make -C pkg/gnu/gcc make -C pkg/gnu/gcc install The second step could also be changed to speed up for an N-core system: make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL=”-jN”

How to disable a particular unknown #pragma warning (GCC and/or Clang)

I’m reasonably sure that there isn’t any way to do this. Both GCC and Clang do have internal interfaces which allow the language frontend to register #pragma handlers with the preprocessor – see GCC’s libcpp/directives.c and Clang’s lib/Lex/Pragma.cpp – but, as far as I can see, there is nothing which lets you modify which handlers … Read more

Specify OpenMP to GCC

In general, keep in mind that the directives and the functions are different things; the former are controlled by -fopenmp and the latter are controlled by linking to the OpenMP library. (Updated to incorporate comments) Try using the -fopenmp and -static options to statically link OpenMP. Because this implies -lgomp -lrt, the following command won’t … Read more

Implementation of nested functions

GCC uses something called a trampoline. Information: http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html A trampoline is a piece of code that GCC creates in the stack to use when you need a pointer to a nested function. In your code, the trampoline is necessary because you pass g as a parameter to a function call. A trampoline initializes some registers … Read more