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] |
- From: Josh Conner
- To: gcc at gcc dot gnu dot org
- Cc: Mark Mitchell , Jason Merrill , Nathan Sidwell
- Date: Tue, 01 Nov 2005 08:52:46 -0800
- Subject: [RFC] c++ template instantiation generates zero-sized array (pr 19989)
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:
- by default: accept it with no warnings/errors
- with -pedantic: generate an error
- with -pedantic -fpermissive: generate a warning
For the second example (the function template), I believe gcc should:
- by default: bind to the second foobar
- with -fpermissive: bind to the first foobar (which will generate a duplicate matching template error)
- with -fpermissive -pedantic: bind to the first foobar, with a warning (also generating a duplicate matching template error)
Is this an accurate summary of what we'd like to see?
Thanks -
Josh
- Follow-Ups:
- Re: [RFC] c++ template instantiation generates zero-sized array (pr19989)
* From: Mark Mitchell
- Re: [RFC] c++ template instantiation generates zero-sized array (pr19989)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |