This is the mail archive of the
mailing list for the GCC project.
Re: [patch] for PR 18040
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: zack at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 17 Oct 04 18:29:23 EDT
- Subject: Re: [patch] for PR 18040
> ... actually, it's not good enough because it doesn't handle the
> ((cast) var).field
> case and that's an expensive one.
My gut feeling is that needing this cast means there's something wrong
with the static type of VAR. Could you show an example of source code
that needs this cast, and the type tree generated for VAR?
Well, in Ada you can get it with an explicit Unchecked_Conversion to a
composite type. For example:
function foo return integer is
type arr is array (1..100_000) of integer;
type r is record
f2: array (1..99_999) of integer;
return uc (foo).f1 + foo (2000);
The type of FOO has to be an array of 100,000 integers, but the
programmer would be quite surprised if the reference to F1 involved a
400,000 byte copy!
This is, admittedly, a somewhat contrived example, but this sort of
thing occurs commonly in expanded code for different constructs.