[Bug c/56465] Strange warning about variable modified range

jasonwucj at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 28 17:19:00 GMT 2013


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

Chung-Ju Wu <jasonwucj at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jasonwucj at gmail dot com

--- Comment #3 from Chung-Ju Wu <jasonwucj at gmail dot com> 2013-02-28 17:19:13 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > >it is actual a constant.
> > 
> > I don't think it is a integer constant expression though as it contains a cast
> > from a pointer type to an integer type.
> 
> Well, it isn't a integer scalar, but still a constant.

To my understanding, it is not a constant.

For example, 

  int i;
  i = (int) ((int*)0 + 1);

Could you tell the value of i from C language point of view?

According to C99 6.5.6 Point 8, 
"When an expression that has integer type is added to or subtracted
 from a pointer, the result has the type of the pointer operand."

Hence, the result of "(int*)0 + 1" is a 'pointer to type T'.
So, no, you can't tell the value.
It depends on integer size of target machine.



More information about the Gcc-bugs mailing list