This is the mail archive of the gcc-bugs@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]

[Bug c/22278] gcc -O2 discards cast to volatile


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-02 17:42 -------
Since the orginal pointer is not violatile the cast will not change any thing since the compiler can  
deduce it is not violatile.
>From C99, 5.1.2.3 P3:
In the abstract machine, all expressions are evaluated as specified by the semantics. An actual 
implementation need not evaluate part of an expression if it can deduce that its value is not used and 
that no needed side effects are produced (including anycaused by calling a function or accessing a 
volatile object). 

and since violatile applies the type which is being pointed to and not to the pointer, the compiler can 
deduce it is not needed.
Casting away the violatile in a pointer changes the behavior (just like const).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278


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