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++/35669] NULL (__null) not considered different from 0 with C++



------- Comment #10 from bangerth at gmail dot com  2009-04-29 12:51 -------
There is really nothing much that can be done within the current C++
standard. In C, NULL is defined as 
  (void*)0
which can be converted to any other pointer and so is clearly marked
as a pointer. The compiler can then warn when passing it to an integer
argument of a function.

In C++, we have [18.1/4] "The macro NULL is an implementation-defined C++ null
pointer  constant in this International Standard (_conv.ptr_).180)" and
footnote 180 specifically says:

  180) Possible definitions include 0 and 0L, but not (void*)0.

This is because void* is not implicitly convertible to any other pointer
type and so NULL could not be assigned to other pointers. As a consequence,
since NULL can not in an obvious way be a pointer, there is no obvious
warning that can be generated.

The situation will be different with the upcoming C++1x standard where there
is null_ptr.

W.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


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


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