Re: contiguity of arrays
From: Wojtek Lerch (Wojtek_L_at_yahoo.ca)
Date: 10/04/04
- Next message: Tim Rentsch: "Re: What is a type?"
- Previous message: Artie Gold: "Re: segmentation fault - code attached"
- In reply to: David Hopwood: "Re: contiguity of arrays"
- Next in thread: David Hopwood: "Re: contiguity of arrays"
- Reply: David Hopwood: "Re: contiguity of arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 3 Oct 2004 23:29:13 -0400
"David Hopwood" <david.nospam.hopwood@blueyonder.co.uk> wrote in message
news:C7L7d.185576$hZ3.39917@fe2.news.blueyonder.co.uk...
> Wojtek Lerch wrote:
>> What you seem to be saying is that for a region of memory to constitute
>> an array of four ints, it doesn't have to be declared with a type that
>> involves an array of four ints, or designated by an lvalue with such a
>> type, but nevertheless it must be declared with some aggregate type
>> ultimately consisting of four ints and no padding bytes between them.
>
> Yes. This view is based on the definition of "array type" as being the
> type
> of any contiguous nonempty sequence of objects of the element type. In
> order
Not just *any* contiguos sequence. A struct type that consists of four ints
and turns out to have no padding bytes is not an array type. It's a struct
type.
> to perform an access via a given pointer, say of type T, you need to be
> able
> to infer that it currently points to a region that *can* hold an object of
> type T. The memory allocation functions are a special case that return
> pointers to regions able to hold objects of any type.
That is not a very accurate wording: regions of memory don't hold objects,
they are objects. An allocated object can be given any effective type by
using an lvalue of that type to store a value in the object. But when it
has an effective type, it's one type. When it's a struct, it's not an array
of int.
>> But, I presume, possibly with some extra stuff after the four ints. Is
>> that more or less correct? Do you have a way of describing it that
>> doesn't feel arbitrary and inconsistent?...
>
> Not particularly. It would help if the definitions of "object", "array"
> etc.
> in the standard were clearer.
- Next message: Tim Rentsch: "Re: What is a type?"
- Previous message: Artie Gold: "Re: segmentation fault - code attached"
- In reply to: David Hopwood: "Re: contiguity of arrays"
- Next in thread: David Hopwood: "Re: contiguity of arrays"
- Reply: David Hopwood: "Re: contiguity of arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|