https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87199
Ev Drikos <drikosev at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |drikosev at gmail dot com --- Comment #2 from Ev Drikos <drikosev at gmail dot com> --- (In reply to Eric Gallager from comment #1) > My first guess would be that the difference is Linux has native TLS, whereas > macOS only has emutls, which would be bug 52268. I'll wait for someone else > to confirm, though. Not really sure if my response is indeed the confirmation you want. If I compile the above example in macOS High Sierra (10.13) with the much older GNU gcc-4.8.5, then the output is "constest". Whereas with the newer gcc-8.2 I see the same results with the OP. $ g++ --version && uname -r g++ (GCC) 4.8.5 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17.5.0 $ g++ -g -std=c++11 -c -I . main.c $ g++ -g -std=c++11 -c -I . lib.cpp $ g++ -o main main.o lib.o $ ./main constest$ $ g++8 -g -std=c++11 -c -I . main.c $ g++8 -g -std=c++11 -c -I . lib.cpp $ g++8 -o main main.o lib.o $ ./main $ Ev. Drikos