This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [gimple] assignments to volatile
> > On 06/23/10 19:36, Mike Stump wrote:
> >> C++ says:
> >
> > C and C++ differ in their cast-to-void behaviour. In particular, in
> C++
> > (void)obj;
> > does not cause a read of obj, because no lvalue->rvalue decay
occurs.
> This is very confusing for volatiles and incompatible with established
> C semantics. As such G++ will cause a read of a volatile scalar obj
in
> these cases.
>
> Yeah, this was one of the later changes that I groaned over when it
> went in, I wish the C and C++ standards people were on the same page.
> If they are to differ, I would not be against just making the
construct
> an error, to prohibit people from making any use of a semantic that
> isn't the same in both languages. I know the status quo is to just
> conform to the C semantic, and I didn't argue or object to that; it's
> just an unfortunate position to be in. However, since we went in that
> direction, I wish people would formulate a change for the C++ language
> consistent with that and get that in, say, in the name of C
> compatibility.
As I see it, for C++ to deviate from C in this respect is a C++ bug.
Making such a construct an error in C++ programs is probably a bit
strong, but I would want to see it be a warning (on by default).
paul