News for hackers. Stuff that matters.
Re:Flattening ASTs (and Other Compiler Data Structures) by azornathogron on Sunday July 02, 2023 @01:26PM (#36563541)
Compilers (for C and C++) typically provide mechanisms to control padding and other layout requirements as necessary to make this work.

It's not that unusual in C and C++ code to define a struct that has a specific and well-defined memory layout. It's kosher, as long as you accept that you're working with a specific set of real compilers and use the appropriate #pragmas or other controls as needed to avoid undefined behaviour.

Re:Flattening ASTs (and Other Compiler Data Structures) by bjourne on Sunday July 02, 2023 @09:38PM (#36567685)
Yep, but then you force the compiler to choose a specific struct-layout which may be suboptimal if, for example, coding for simd. You also can't control the values of the struct padding bytes which may cause very interesting bugs.