------- Additional Comments From jconner at apple dot com 2005-09-03 02:09 ------- When generating a precompiled header, finish_member_declaration() invokes note_decl_for_pch() for the function "testfn<T>", and assigns it to the COMDAT section with weak linkage.
Then, when the test.C file is compiled, a function "testfn<int> (implicit declaration)" is generated, and inherits the COMDAT properties of "testfn<T>". Finally, when the explicit specialization is actually seen, the function duplicate_decls() attempts to merge the declarations, and assigns the specialization function (incorrectly) to the COMDAT section. When not using precompiled headers, the "testfn<T>" function is not assigned to the COMDAT section until after its attributes are merged with the specialization by duplicate_decls(), and since checks are already in place to make sure that the specialization doesn't inherit the DECL_DECLARED_INLINE_P attribute (which is a prerequesite for ending up in COMDAT), both decls are assigned to the correct sections. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23708