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

Re: Variable-sized types vs. templates


Mark Mitchell wrote:

> is likely not the only problem with variably-sized types.  I'll bet that
> `typeid' and `dynamic_cast' do not behave sensibly in conjunction with
there was a bug report about typeid. IIRC, it now produces a
compile time error - It's just typeid (vla),
and not typeid (contains_vla). I suspect typeid (void (*)(VLA *))
and typeid (VLA *) are not handled gracefully. 

I don't think dynamic_cast has a problem.

> Therefore, we need to define a rule that allows us to diagnose the above
> cases.  That's not easy.  For example, if T is a VLA type, or a type
A<VLA> - compile error
A<VLA*> - compile error
A<contains_VLA> - probably ok.
A<void (*)(VLA**)> error
A<S*> compile error

The problematical ones are those that require the mangling of the
VLA. We either ban that, (with the above implications), or
specify that all VLA's of the same element type are 'the same'

> I do not fancy having to recursively walk the type tree every time we
> instantiate a template; that will make our already slow template
> instantiation process even slower.  Neither do I fancy having to keep
> a bit on each and every type as we build them; the compiler creates
> types in too many places using too many methods to make this easy to
> get right.
Yup, I remember being rather stunned when I discovered that uses_template_parms
did such a walk. How about a set of lazy cache bits along with a valid
bit. If valid is false, we do the walk, filling everything in, and
then set the bit. This is a bigger solution than I'm sure you and I
are happy with.

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


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