Does accessing enums through int pointers break the strict aliasing rule? Or are enums treated as ints?
This is a discussion on enums and strict aliasing rule within the C++ Programming forums, part of the General Programming Boards category; Does accessing enums through int pointers break the strict aliasing rule? Or are enums treated as ints?...
Does accessing enums through int pointers break the strict aliasing rule? Or are enums treated as ints?
Incompatibilities Between ISO C and ISO C++
enums might not even be the same SIZE as an int, so no, stop thinking about whatever it is you're trying to do.
Unless you're posting on C++ just to keep things interesting...
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
Ah! I wasn't aware of that.
Thanks
I believe that in C++0x you can do this:
To force it to be of integer size. Though I'm not 100% sure about this and have no time to verify atm.Code:enum SomeName : int {
Why would you want to acess an enum through an int pointer?
Arrogance breeds bad code
It's a function that is overloaded for a bunch of basic types, but not enum types, so I thought maybe I can just use the int version.
Ended up doing something completely different.