This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++ and null pointers
- From: Falk Hueffner <hueffner at informatik dot uni-tuebingen dot de>
- To: Eljay Love-Jensen <eljay at adobe dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Aug 2004 12:53:59 +0200
- Subject: Re: g++ and null pointers
- References: <6.1.2.0.2.20040824053102.01e9b890@iplan-mn.corp.adobe.com>
Eljay Love-Jensen <eljay@adobe.com> writes:
> When I compile this test.cpp source...
>
> // g++ -Wno-long-long -pedantic -Wall -W -c test.cpp
> #define NULL __null
> int main()
> {
> void* p;
> p = 0;
> p = 0u;
> p = 0ul;
> p = 0ull;
> p = 0l;
> p = 0ll;
> p = false;
> // silly...
> p = -0;
> p = -0u;
> p = -0ul;
> p = -0ull;
> p = -0l;
> p = -0ll;
> p = -false;
> // my druthers...
> p = NULL;
> return 0;
> }
>
> ...GCC is happy with all of these assignments.
>
> Are they all supposed (ISO 14882) to be legit? Some of them surprised me.
The standard says that a null pointer constant is "[a]n integer
constant expression with the value 0", so these seem all OK.
--
Falk