------- Comment #1 from rguenth at gcc dot gnu dot org 2009-07-11 17:53 ------- Cases like
t1.c int i = 2; t2.c int i = 1; int main() { return i; } are diagnosed by the linker - not ideal, but not different from -fno-lto either. Index: lto-symtab.c =================================================================== --- lto-symtab.c (revision 149512) +++ lto-symtab.c (working copy) @@ -568,15 +568,17 @@ lto_symtab_merge_decl (tree new_decl, if (resolution == LDPR_PREVAILING_DEF || resolution == LDPR_PREVAILING_DEF_IRONLY) { - if (old_resolution == LDPR_PREVAILING_DEF - || old_resolution == LDPR_PREVAILING_DEF_IRONLY) + if ((old_resolution == LDPR_PREVAILING_DEF + || old_resolution == LDPR_PREVAILING_DEF_IRONLY) + && old_resolution != resolution) { error ("%J%qD has already been defined", new_decl, new_decl); error ("%Jpreviously defined here", old_decl); return; } gcc_assert (old_resolution == LDPR_PREEMPTED_IR - || old_resolution == LDPR_RESOLVED_IR); + || old_resolution == LDPR_RESOLVED_IR + || old_resolution == resolution); lto_symtab_set_identifier_decl (name, new_decl); return; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40721