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

Krzysztof Parzyszek kparzysz at codeaurora.org
Fri Apr 11 16:45:37 PDT 2014


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

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list