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

g++ and null pointers


Hi everyone,

GCC 3.3.1 on Cygwin

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 negated ones are just for fun. I didn't go completely crazy with the cheese whiz, and put in "!!0" and "+0" and hexadecimal, and octal, and various permutations of the [uUlL]* suffix.

Sincerely,
--Eljay


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