This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17232] classes and class template specializations treated differently w.r.t. core issue #337
- From: "cludwig at cdc dot informatik dot tu-darmstadt dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Aug 2004 16:56:12 -0000
- Subject: [Bug c++/17232] classes and class template specializations treated differently w.r.t. core issue #337
- References: <20040829175551.17232.cludwig@cdc.informatik.tu-darmstadt.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From cludwig at cdc dot informatik dot tu-darmstadt dot de 2004-08-30 16:56 -------
Subject: Re: classes and class template specializations treated differently w.r.t. core issue #337
On Mon, Aug 30, 2004 at 04:05:26PM -0000, bangerth at dealii dot org wrote:
>
> So do we agree that the problem in this PR is really this:
> - for the non-template, the compiler realizes that B is abstract
> and that therefore no array type can exist; it therefore rejects
> the template version of g and goes with the general one
> - for the template class A, the compiler doesn't realize the
> abstractness and therefore goes with the template version of g
> Is this indeed the reason the testcase fails?
Yes, that's correct.
Perhaps the testcase becomes clearer if you change main() into
int main() {
return g< A<int> >(0) + 2 * g< B >(0) ;
}
I'd expect the return value 3 since both classes are abstract and (IMO)
the second overload should be chosen in both cases according to the
resolution of DR#337 and the SFINAE principle.
But gcc 3.4.1 returns 2, exhibiting that the compiler chose the
overloads g< A<int> >(A<int>(*)[1]) and g< B >(...),
> I double-checked that
> if I remove the '=0' declaration in the two classes, that the testcase
> really succeeds.
That's correct behaviour. Once the classes are no longer abstract the
substitution T = B and T = A<int> into T(*)[1] yields a valid
expression and g(T(*)[1]) can take part in overload resolution. DR#337
does not apply.
Since any match is considered better than the ellipsis, g(T(*)[1]) is
chosen both for T = B and T = A<int>.
Regards
Christoph
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17232