Daniel Berlin wrote:

> How does this reasoning not apply to *((char *)a) = 5 where a was
> originally of a const qualified type?
> Or do you think you can only *add* qualifiers, and not remove them?
> 
> Because if you allow casting away, then you can't ever trust const to be
> true either, just like we apparently can't trust the user saying "this
> is not volatile" (which they are doing by not declaring the original
> object volatile).

I don't understand your point. given
        void Foo (char const * a) { *(char *)a = 5; }
the compiler generates code to store 5 through the pointer 'a'.  It doesn't turn
this into a call to 'abort', because it thinks you're writing to const storage.

So, here it appears the compiler does believe the (char *) cast.  Why should it
not believe a (char volatile *) cast -- unless it can determine the static type
of the object pointed to?

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
[EMAIL PROTECTED]    ::     http://www.planetfall.pwp.blueyonder.co.uk

Reply via email to