[PATCH] Fix PR71598, aliasing between enums and compatible types
Michael Matz
matz@suse.de
Tue Mar 19 09:38:00 GMT 2019
Hi,
On Tue, 19 Mar 2019, Richard Biener wrote:
> It doesn't really. Consider the following IMHO valid testcase:
>
> enum X { A, B };
> enum Y { C, D };
> void foo (int *p)
> {
> *(enum X *)p = A;
> *(enum Y *)p = D;
> return *(enum X *)p;
> }
>
> int main()
> {
> int storage;
> if (foo (&storage) != A)
(You want to require 'B' here, not 'A')
> abort ();
> }
If you want the above testcase to be valid then yes, I agree, you have to
give all enums the same alias set as the underlying type. Meh, I don't
like it :-/
Ciao,
Michael.
More information about the Gcc-patches
mailing list