This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: zero-sized arrays not allowed within templated structdefinitions?


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]