Re: Warning: The structure contains misaligned fields



jamesgiles@xxxxxxx wrote:
On Apr 28, 11:35 am, Craig Powers <eni...@xxxxxxxxxx> wrote:
...
The significance of SEQUENCE is that identically-declared types will be
treated as identical (i.e. if you were to repeat your declaration of
type(ccc) in a subroutine, it would be identical to the type(ccc)
declared in the module and one could be used as an actual argument
corresponding to the other as a dummy argument). The name implies that
the memory layout will be exactly as declared, but the standard does not
actually impose such a requirement.

It doesn't usually say anything about memory layout as such. However,
since SEQUENCE derived types may be used in COMMON and the components
be storage associated through that COMMON with non-derived-type
variables, it's hard to imagine how it would be implemented without
actually being in the order declared.

Depending on what restrictions are imposed on COMMON, it might be feasible for the compiler to automatically re-order to avoid alignment issues, as long as that re-ordering were applied consistently across all contexts.
.



Relevant Pages

  • Re: Common programming mistakes?
    ... I think of some kind of list that states the most common ... programming errors together with their frequency and the cost to find ... a declaration hides another declaration ... uninitialized memory (eg: using malloc and forgetting to use memset or such ...
    (comp.lang.misc)
  • Re: Return value of _time64() in VS2005
    ... >The common description of timeand _time64() says that the function ... >declaration above. ... referring to times between 1903 and 1970. ...
    (microsoft.public.vc.language)
  • Re: Common block file
    ... The bulk of the files are auto declared using the i-n option ... In that case you are going to have to keep the common statement inside the module - because it's the only declaration of the variables. ... That doesn't hurt, but it will make it a bit more awkward to make some other modernisations/improvements (such as making some of the arrays allocatable, allowing greater flexibility in the size of problem you can consider) - you can't do that with an array in common, but you can with an array in a module. ...
    (comp.lang.fortran)
  • Re: variable changes value spontaneously
    ... > their type declared in the common statement. ... I claim that the type information is not then in the common statement. ... The typ[e information comes from the implicit statement. ... type declaration statements either), ...
    (comp.lang.fortran)
  • Re: D3, Common, and @variables, any required order??
    ... The general requirement of compilers is that a Common variable cannot be ... than the Main declaration in subs. ... in a subroutine can be anywhere or not at all. ...
    (comp.databases.pick)