[LLVMdev] Advice on field access, adding a Modula-3 front end

Rodney M. Bates rodney_bates at lcwb.coop
Sat Apr 12 10:23:55 PDT 2014


OK, thanks.  I will proceed on that assumption.  I'll use packed where I
need to fully control the layout.

On 04/11/2014 06:45 PM, Krzysztof Parzyszek wrote:
> On 4/11/2014 6:23 PM, Rodney M. Bates wrote:
>>
>> So it looks like StructLayout::Structlayout does _not_ reorder
>> non-packed fields.
>> Can I rely on this?  I thought I remembered reading something to the
>> contrary somewhere in the documentation.
>
> C (and C++ to some extent), both have certain kinds of guarantees as to the memory layout (at least as much as it can be observed by the program's execution). If the optimizer could assume its own ordering of the members, it would introduce binary incompatibilities with other compilers and cause a lot of things to break.  While I don't remember seeing any explicit guarantees in the documentation, I think it's a pretty safe assumption (for both packed and non-packed aggregates).
>
> -Krzysztof
>

-- 
Rodney Bates
rodney.m.bates at acm.org



More information about the llvm-dev mailing list