https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97771
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Erez Strauss from comment #7) > Hi Andrew, > > Here is a very simple test program, under clang++ its output is 3, as > expected. Right I already mentioned this is a dup of still opened bug 88061 . The problem is clang might be emitting really really broken assembly and only can be resolved at link time. Take: template<typename T> void funcB() { static funcP init_func [[gnu::used, gnu::section(".init_array")]] { []()->void{++X;} }; } ----- CUT ----- funcB<int>::init_func has to be the same between TUs and that means emiting it in the comdat section. In fact the use of X here might actually cause this code to be full on invalid anyways.