Josh Conner wrote: > I've been investigating PR 19989, where we are rejecting code when a > template instantiation generates a zero-sized array, such as: > > template<int> struct A > { > static const int i = 0; > } > > template<int N> struct B > { > int x[A<N>::i]; > }; > > B<0> b; > > This is rejected on the grounds that not failing could generate an > incorrect match in other instances
I understand what you're after: tolerate uses of the extension where it's sufficiently harmless. I don't think your proposed solution is correct, though, because we want to maintain the invariant that all conforming programs compile and behave as required by the standard in all compilation modes. In other words, supplying -fpermissive and friends can make non-conforming programs compile, when they otherwise wouldn't, but conforming programs should behave identically in all modes. I would imagine that if we encounter a zero-sized array when the "complain" flag is tf_error, then we can just issue a conditional pedwarn, with "if (pedantic) pedwarn (...)". But, if tf_error is not set, we must reject the instantiation. I know that sounds backwards. The point is that when tf_error is set, we're committed to the instantiation. When tf_error is not set, SFINAE applies. And, in a conforming program, we must reject the instantiation in that case. -- Mark Mitchell CodeSourcery, LLC [EMAIL PROTECTED] (916) 791-8304