This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/22278] gcc -O2 discards cast to volatile
- From: "falk at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Jul 2005 23:45:52 -0000
- Subject: [Bug c/22278] gcc -O2 discards cast to volatile
- References: <20050702164323.22278.olivier.baudron@m4x.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From falk at debian dot org 2005-07-02 23:45 -------
(In reply to comment #19)
> How about this?
>
> int foo;
> *(volatile int*) (&foo);
>
> In other words, why should the compiler bother at all with the qualifiers of
> what the pointer "really" points to?
Because the standard says so. As Nathan Sidwell explains in the thread
linked above, it would be both pretty difficult to define the language
extension you want semantically clean, and to implement it in gcc. So
nobody tried yet. (Giving a warning would probably be less difficult to
implement, unfortunately nobody tried either.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278