That’s a good point, I didn’t think about embedding into a larger type having some of the same problems. In general though it should always be fine to spend a little extra space in the C++ side; the problem happens if (a) C++ and Swift have different layouts for the fields of a larger type, (b) C++ tries to load from a Swift-managed address and the padding is unloadable (probably only affects ASan), or (c) C++ tries to write to the Swift storage and overwrites subsequent memory with garbage.
2 Likes