This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/77615] Template specialization is resolved differently with and without optimizations turned on


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77615

--- Comment #2 from Jan Bujak <jan.bujak at nokia dot com> ---
(In reply to Markus Trippelsdorf from comment #1)
> Please read: https://isocpp.org/wiki/faq/templates
> 
> * Why can’t I separate the definition of my templates class from its
> declaration and put it inside a .cpp file?

Yes, I was aware of that, and it does make sense from a *technical* standpoint,
but I reported the bug anyway because this is a potential landmine waiting to
go off. You'll probably disagree, but for me changing the optimization level
should *not* subtly change the behavior of the code without even a warning!

If doing this is incorrect then the compiler should at least generate a warning
instead of silently generating wrong code. The compiler knows that the template
was defined in a header file, and it knows that the specialization was defined
in a .cpp file, so it could tell the user that "hey, that probably won't work
as you think it should; if you know what you're doing then feel free to silence
this warning".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]