Re: two issues with unsigned int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/8/2010 9:55 AM, brac37 wrote:
>
> The designers of c++ wanted people to write, or at least be
> able to write
>> PointerType p = 0;
> or
>> PointerType p (0);
> instead of
>> PointerType p = NULL;
> or
>> PointerType p (NULL);
> For that purpose, the copy constructor from integers to pointers
> was made implicit. Therefore, the compiler does not know what
> implicit copy constructor to choose: (unsigned int)(int) or
> (int *)(int).
>
> My opinion was already before running into this issue that the
> designers of c++ made a bad choice here. But given that choice,
> it would be nice when the compiler should choose integer conversion
> whenever possible before complaining about ambiguity.

If the standard says that zero is implicitly convertible to a pointer value, the ambiguity introduced by those two methods is mandated by the standard.

As I understand things, GCC (or any compliant compiler) cannot simply "choose integer conversion whenever possible before complaining about ambiguity" without violating the standard.

So whether the designers of C++ made a bad choice regarding this feature or not, it is (perhaps unfortunately) something that the GCC developers can do little about, short of writing some sort of GCC-specific extension/flag that behaves according to your wishes.

Of course, since GCC is free software, you are free to download the source code and change it to work however you like.

--
Tony Wetmore




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux