This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: zero-sized arrays not allowed within templated structdefinitions?
- To: Seapig6 at aol dot com
- Subject: Re: zero-sized arrays not allowed within templated structdefinitions?
- From: mark at codesourcery dot com
- Date: Sat, 22 May 1999 14:28:15 -0700
- Cc: egcs-bugs at egcs dot cygnus dot com, kosak at cs dot cmu dot edu
- Organization: CodeSourcery, LLC
- References: <4401d28.24785492@aol.com>
>>>>> "Seapig6" == Seapig6 <Seapig6@aol.com> writes:
Seapig6> [if you need to reply to me directly, please use the
Seapig6> kosak@cs.cmu.edu address]
Seapig6> Is there a reason why the g++ extension that permits
Seapig6> zero-length arrays is not permitted within templated
Seapig6> structs?
Yes, but it's bizzarely techincal. The creation of a zero-sized array
should (by the standard) cause a failure of argument deduction. Thus,
candidates depending on this should not be available for overload
resolution. So, for example, a function like:
template <int I> foo (int (&i)[I], int (*j)[I - 1] = 0);
int i[1];
foo (i); // No matching function.
Now, imagine that there were another overload for `foo'. Then, we
should pick it, even if (were we to consider both candidates), there
would be an ambiguity. The same thing applies if the parameters to
`foo' are classes whose members would have zero-sized array types, and
so forth recursively.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com