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

Re: ANSI requirement

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
June 12, 2010 05:28
Subject:
Re: ANSI requirement
Message ID:
20100612122820.GG31795@plum.flirble.org
On Fri, Jun 11, 2010 at 10:16:05AM -0700, Jan Dubois wrote:
> On Fri, 11 Jun 2010, Æ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, such as the the offset into
> > a struct being the sum of the sizeof() of the struct members that came
> > before in the struct.
> 
> I seriously doubt that we rely on it because it would not work unless
> there is *no* structure padding at all.  Nicholas has been working hard
> to remove most unused padding, but I don't believe there is any code in
> Perl that is adding up sizes of individual struct members.

Yes, that's what I thought too :-)

> And anyways, ANSI C has the offsetof() macro if you ever really need to
> know an explicit offset.

Although I did get tripped up by aggressive but legal Sparc64 compilers -
they're allowed to take advantage of the alignment constraints of a struct
when accessing its members. The case in question was loading two adjacent
32 bit values from an 8-byte aligned structure.

We don't make that mistake now.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About