List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 18 2011 7:02am
Subject:Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221
View as plain text  
On 2011-05-16 18:04, Davi Arnaut wrote:
> My concern is about alignment of the subsequent elements of the array. 
> I think we can rely on the compiler to add padding after the last 
> member to ensure that each element in a array of the type is aligned.
>
> Regards,
>
> Davi 

aha. I did some investigations:

struct foo
{
    long long i;
    char c;
};

sizeof(foo) will typically be 16, i.e. include the necessary padding, in 
case we want to
have an array of foos, and do pointer arithmetic or array indexing.
So effectively there is no padding "between elements" of an array,
rather the padding is within each struct.

I also found this quote somewhere:

[5.3.3.2] When applied to a class, the result [of the sizeof()
operator] is the number of bytes in an object of that class including
any padding required for placing objects of that type in an array.

-- didrik

Thread
bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen13 May
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Davi Arnaut13 May
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen16 May
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Davi Arnaut16 May
        • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen18 May