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/22485] pointer +- integer is never NULL


------- Additional Comments From falk at debian dot org  2005-07-14 21:47 -------
Subject: Re:  pointer +- integer is never NULL

Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

> "falk at debian dot org" <gcc-bugzilla@gcc.gnu.org> writes:
>
> | ------- Additional Comments From falk at debian dot org  2005-07-14 15:37 -------
> | (In reply to comment #7)
> | 
> | > I'm failing to find anything in the C++ standard that suggests that the
> | > following shall be undefined
> | > 
> | >    (reinterpret_cast<int*>(0) + 5) - 5
> | 
> | If (reinterpret_cast<int*>(0) + 5) - 5 is not undefined, then neither is
> | reinterpret_cast<int*>(0) + 5. Then what is its result, by which paragraph
> | in the standard?
>
> The standard says that the mapping used by reinterpret_cast to turn an
> integer into a pointer is *implemented-defined*.  It is not undefined.
> GCC uses the "obvious" mapping, which is reinterpret_cast<int*>(0) is
> the null pointer.

So your example boils down further to the question of whether
((int*)0) + 5 is undefined, but you didn't answer my question
yet. What is the result of ((int*)0) + 5, by which paragraph in the
standard?



-- 


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


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