This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Union an alias when the difference is the volatile qualifier?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 3 Aug 2015 13:43:51 -0400
- Subject: Re: Union an alias when the difference is the volatile qualifier?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8memwTgcYFZuABvg+wt1fEavdouey5wmE6YkPNqdVb00Q at mail dot gmail dot com> <55BE28D5 dot 1050702 at redhat dot com> <CAH8yC8ms_cMS=SMQ7ae2bvPadwBN4xOXcRjarZOQA41ufQm1jQ at mail dot gmail dot com> <55BFA761 dot 1020907 at redhat dot com>
- Reply-to: noloader at gmail dot com
>>> It's OK to cast a pointer to int to a pointer to volatile int and then
>>> dereference that pointer, but not vice versa. So, GCC must assume
>>> that a pointer to volatile int may point to a non-volatile int object.
>>> But the reverse is not true: GCC need not assume that a pointer to int
>>> may point to a volatile int.
>>
>> One last question, and then I will be done. Is it OK to do in C++03 and above.
>
> I don't think that there is any difference between C and C++ in this
> regard, nor any intention to change it in later standards. To break
> compatibility in this way would be catastrophic for a lot of software.
Thanks Andrew. /EOM.