Message398067
Adding a new enumerator to a C enum can change the size of the type,
which would break the ABI.
This is not often a problem in practice, but the rules around when it is a problem and when it isn't are complicated enough that I believe enum should not be used in the stable ABI (possibly with well-reasoned exceptions)
AFAICS, the rules are:
- In C++, an incompatible change to an enum is one that changes the size of the *smallest bit field large enough to hold all enumerators*. Values outside the range cause undefined/unspecified behavior.
- In C, it looks like enums that fit in `char` are safe.
(Also, the compiler-defined size of enums will make it more cumbersome to formally define an ABI for non-C languages.) |
|
Date |
User |
Action |
Args |
2021-07-23 15:23:37 | petr.viktorin | set | recipients:
+ petr.viktorin |
2021-07-23 15:23:37 | petr.viktorin | set | messageid: <1627053817.9.0.30877505306.issue44727@roundup.psfhosted.org> |
2021-07-23 15:23:37 | petr.viktorin | link | issue44727 messages |
2021-07-23 15:23:37 | petr.viktorin | create | |
|