This is pretty much the same question as Does adding enumerators into enum break ABI?, but with enum class
introduced by C++11.
For what I understand by this page I can simply have a stable ABI by defining an underlying type for my enumerative:
enum class Foo : uint32_t
{
x, y, z
}
I would say this works fine, as for instance something like
enum class Foo : uint8_t { x = 257 }
Will not compile. This implies that the compiler is no longer silently changing the size of my enumerative, thus I don't end up in breaking binary compatibility.
Am I correct?
I believe the accepted answer to the referenced question answers most of the issues with respect to ABI compatibility. I could repeat it here but I don't see much value there.
To address you specific question about C++11 scoped enumerations your example:
is ill-formed since it requires a narrowing conversion, the implementation is required to provide a diagnostic but it may compile if the implementation only makes it warning for example. As you ask, the compiler won't silently change the size of underlying type.
We can see this from the draft C++ standard dcl.enump5:
and converted constant expression forbid narrowing conversion, from expr.constp5: