Josh Conner - [RFC] c++ template instantiation generates zero-sized array (pr 19989) (original) (raw)

This is the mail archive of the gcc@gcc.gnu.orgmailing 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]
Other format: [Raw text]

I've been investigating PR 19989, where we are rejecting code when a template instantiation generates a zero-sized array, such as:

template struct A { static const int i = 0; }

template struct B { int x[A::i]; };

B<0> b;

This is rejected on the grounds that not failing could generate an incorrect match in other instances, e.g.:

template void foobar (int (*) [M] = 0 ); template void foobar ( );

void fn (void) { foobar<0>(); }

Where we are required to match the second form of foobar.

Before I propose a patch for this behavior, however, I'd like to understand the most desirable behavior (understanding that implementation complexity may limit what is possible in the short term). For my first example (the class template), I believe gcc should in an ideal world:

For the second example (the function template), I believe gcc should:

Is this an accurate summary of what we'd like to see?

Thanks -

Josh


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