https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64504
--- Comment #6 from Andrey Vihrov <andrey.vihrov at gmail dot com> --- Thanks for your reply. You have a point: using -fwhole-program introduces more effects than needed, as evidenced by this bug report, so an anonymous namespace is safer and cleaner. In any case, in this bug report we have a program that produces unexpected results with GCC. If this usage is supported, then it is a bug. If this usage is unsupported, then it would be nice to explicitly document cases when -fwhole-program can be used in GCC. For example, GCC documentation might say something like Note: -fwhole-program can be specified for programs that link only to the standard C/C++ library (or link to nothing at all), and do not use any template class or function from the standard C++ library.