This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/14500] New: most specialized function template vs. non-template function
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-bugzilla at gcc dot gnu dot org
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 09 Mar 2004 08:03:14 +0100
- Subject: Re: [Bug c++/14500] New: most specialized function template vs. non-template function
- Organization: Integrable Solutions
- References: <20040309045153.14500.bkoz@gcc.gnu.org>
"bkoz at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| While working on c++/13658, I ran into divergent behavior between
| icc 7.1 and g++.
|
| I think g++ is wrong, and that in the code below, the explicitly specialized
| function template is the most specialized function, and should be called.
It looks to me that this is an interaction between "strong using" and
specializations: The most specialized swap() (for vector<>) leaves in
__gnu_norm:: whereas the most general leaves in std::. Therefore, when
you explicitly specialize, the compiler just considers the template in
std:: and forgets about the other one in __gnu_norm::; therefore it
thinks that you're specializing the one in std::. Which is wrong.
It should have collected all swap() reachable through strongly used
namespaces. (Recall that strong using says for all purposes except
mangling, everything is the same).
| By removing the template specialization syntax (ie "template<>"), and trying
| again, I get something that is considered the most specialized. But, why this
| and not the other?
When you remove the explicit specialization marker, you're overloading
with an *ordinary* function and overload resolution prefers
non-templates over templates when given equal chances.
-- Gaby