I met a "strange" thing...
Jonathan Wakely
jwakely.gcc@gmail.com
Wed Dec 10 13:09:00 GMT 2014
On 10 December 2014 at 13:03, Graziano Servizi wrote:
> Hi,
>
> by pure chance, during a copy+paste editing operation of a source code,
> I ended up inadvertently with a code line like the following:
>
> int * x = int();
>
> Well, this code HAD BEEN COMPILED by g++ 4.8.3, and I cannot figure out its
> meaning (from the compiler's point of view).
int() creates an integer with value zero.
In C++03 any integer expression with value zero is a valid null
pointer value, so you can do any of these:
int* p1 = 0;
int* p2 = '\0';
int* p3 = 1-1;
More information about the Gcc-help
mailing list