http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52069
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-31 16:34:33 UTC --- (In reply to comment #5) > Okay, got it; thanks a lot for the ultra-quick reply! > > Wouldn't a diagnostic message be helpful here even if it is not required by > the > standard? After all, the resulting binaries won't work correctly. There's a reason the standard says "no diagnostic required." When compiling libtmpl.so, how is the compiler supposed to know that a different translation unit which it can't see (and which might not even have been written yet) will implicitly instantiate the member? When compiling main.o, how is the compiler supposed to know that an explicit specialization exists in a separate translation unit which it can't see? > I also keep wondering why things do work when optimization is disabled, but I > guess the compiler may do anything it pleases since the input is invalid. With optimisation enabled the compilation of main.o probably removes condition because the constant is known to be zero because there has been no explicit specialization declared. Without optimisation a weak symbol is emitted, which may or may not be replaced by the weak symbol in libtmpl.so that has a different value.