Address of a class object

Ali Çehreli acehreli at yahoo.com
Wed Jan 4 21:53:44 UTC 2023


On 1/4/23 13:43, H. S. Teoh wrote:

 > You do realize that the compiler is free to reorder local variables on
 > the stack, right? ;-)

Of course. :)

I was trying different strategies to catch the compiler (dmd here) in a 
single act of 8-byte object alignment as reported by .alignof.

Another thing the compiler is free for class members is to reorder them. 
I also theorized perhaps the compiler was also considering the alignment 
of a member. But as expected, char[1] does have 1 alignment and it can't 
be the reason in this case. (Again, there is no problem here; we are 
just learning.)

 > implementation-specific details

RazvanN or Dennis may chime in on that.

Ali



More information about the Digitalmars-d-learn mailing list