develooper Front page | perl.perl5.porters | Postings from June 2010

Re: ANSI requirement

Thread Previous | Thread Next
karl williamson
June 11, 2010 12:37
Re: ANSI requirement
Message ID:
Zefram wrote:
> ??var Arnfj??r?? Bjarmason wrote:
>> I vaguely recall someone mentioning that we rely on some features of C
>> that aren't strictly guaranteed by ANSI C,
> Yes, we do.
>>                                           such as the the offset into
>> a struct being the sum of the sizeof() of the struct members that came
>> before in the struct.
> But not this particular one, which is almost never true across a whole
> implementation.  It would require that no data types have any alignment
> requirement.  Implementations almost always use padding in structs.
> There is something similar, though: we do rely on the offset of a struct
> member being *a pure function of* the types of the preceding members.
> (That is, that where two structs begin with type-identical sequences
> of members, the layouts of those members will be compatible.)  This is
> almost always true.
> We rely on a few other things that are almost always true but not
> guaranteed by the standards.  Off the top of my head:
> * that all data pointers have bitwise-compatible representations
> * that function pointers are the same size as data pointers
> * that signed integers are represented in twos-complement
> * that signed integer arithmetic cleanly wraps on overflow
> * that the bits of multi-byte integers are divided up into bytes in
>   adjacent groups, with all bits of each byte participating in the
>   integer representation
> * that bytes consist of exactly eight bits

We do test that bytes are 8 bits in Configure.
> * that all-bits-zero is a valid representation of a null pointer
> -zefram

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About