New submission from Petr Viktorin <encu...@gmail.com>:
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.) ---------- components: C API messages: 398067 nosy: petr.viktorin priority: normal severity: normal status: open title: Stable ABI should avoid `enum` _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44727> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com