This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR71598, aliasing between enums and compatible types


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]