This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77615] Template specialization is resolved differently with and without optimizations turned on
- From: "jan.bujak at nokia dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 16 Sep 2016 09:34:38 +0000
- Subject: [Bug c++/77615] Template specialization is resolved differently with and without optimizations turned on
- Auto-submitted: auto-generated
- References: <bug-77615-4@http.gcc.gnu.org/bugzilla/>
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".