1. 4
  1. 3

    Fascinating, I didn’t realise that C++ had provided so much flexibility. In hindsight, it’s surprising to me that the language standard provides any guarantees given that the C++ committee has historically regarded defining the ABI as an entirely separate concern. This was a big problem for C++ on *NIX before the Itanium C++ ABI was widely adopted (gcc 3.0). Prior to that, GCC revisions felt free to change the C++ ABI between releases. MSVC still does in theory, though the ABI has been fairly stable on Windows for a while.

    It would be nice for ABIs to be allowed to do things like order fields by size to give denser packings but the more flexibility that’s available, the harder it is for compilers to be compatible.

    1. 1

      I’d like there to be some way to tell the compiler “you can reorder the fields past this point”, to opt into size optimizations.

      As it is, whenever I add a bool field to a class in the midst of other fields, I feel dirty.

      1. 1

        Or even just an ability to warn about suboptimal layout.