https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71598
--- Comment #6 from Alexander Monakov <amonakov at gcc dot gnu.org> --- ... and even considering that the standard never actually says that "compatible type" relation is transitive, and so two enums technically need not be compatible with each other, the following should follow the standard to the letter, but is still optimized to 'return 1': enum e1 { c1=2 }; int f(unsigned *p, enum e1 *q) { *p = 1; *q = c1; return *p; }