...
Code Block | ||||
---|---|---|---|---|
| ||||
struct B { int i, j; }; struct D : B { float f; }; void f(D *d) { struct { int i, j; float f; } temp; temp.i = d->i; temp.j = d->j; temp.f = d->f; extern "Fortran" void func(void *); func(&temp); } |
Exceptions
EXP60-CPP-EX1: It is permissible to pass a nonstandard-layout type object across execution boundaries when both sides of the execution boundary adhere to the same ABI. For instance, if the same version of the compiler is used to compile both sides of the execution boundary, or if the compiler used to compile both sides of the execution boundary is ABI-compatible across multiple versions, or if the differing compilers used document that they adhere to the same ABI.
Risk Assessment
The effects of passing objects of nonstandard-layout type across execution boundaries depends on what operations are performed on the object within the callee as well as what subsequent operations are performed on the object from the caller, and can range from correct or benign behavior to undefined behavior.
...