[Bug c++/59475] gcc with flag -O1 fails to find template specialization when there is default one.

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 12 00:58:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59475

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Akela1101 from comment #3)
> Thank you. 
> But could you explain in more detail, why results of this little program are
> different depending on -O1 flag? I thought they both should be 0. Or am I
> wrong?

Because of optimization.  At -O1, the compiler inlines the function ignoring
the one in the other TU.  At -O0, the compiler emits both functions and the
linker randomly chooses which one to use.



More information about the Gcc-bugs mailing list