This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/19989 (4.0/4.1 regression)
- From: "Giovanni Bajo" <rasky at develer dot com>
- To: "Gabriel Dos Reis" <gdr at integrable-solutions dot net>
- Cc: <gcc-patches at gcc dot gnu dot org>,<jconner at apple dot com>,"Mark Mitchell" <mark at codesourcery dot com>
- Date: Thu, 3 Nov 2005 12:33:06 +0100
- Subject: Re: [PATCH] Fix PR c++/19989 (4.0/4.1 regression)
- References: <4369639A.4080404@apple.com> <m3fyqe0z3m.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Josh Conner <jconner@apple.com> writes:
>
>> The attached patches fix PR c++/19989 on the 4.0 and 4.1 branches.
>> Without this fix, code of this form is rejected:
>>
>> template<int> struct A
>> {
>> static const int i = 0;
>> };
>>
>> template<int N> struct B
>> {
>> int x[A<N>::i];
>> };
>>
>> B<0> b;
>>
>> It was rejected because template instantiation was being conservative in
>> not allowing zero-sized arrays, to avoid (correctly) something like this
>> from also being accepted:
>>
>> template<int M> void foobar (int (*) [M] = 0 );
>>
>> void fn (void)
>> {
>> foobar<0>();
>> }
>>
>> Fortunately, we can distinguish between these instances in this code by
>> looking at the complain variable -- when we're committed to applying a
>> template (as in the first case), tf_error will be set.
>
> I'm nervous about this sort of extensions that change function
> overload set -- especially for *conforming* programs, where such
> constructs can happen in the preliminary stage of what is called
> SFINAE. I would like to see more testcases that cover corner cases.
Seconded. Even if it looks that, for this particular construct, we never got
the SFINAE case right, it always errors out (note: I don't know if it's
correct or not that SFINAE doesn't apply here). If that'd be case, this code
should bring no regressions for code which previously compiled correctly.
I'm also nervous because EDG rejects this construct.
--
Giovanni Bajo