c++/5310: Wierd warnings about using (int)NULL

suckfish@ihug.co.nz suckfish@ihug.co.nz
Mon Jan 7 22:46:00 GMT 2002


>Number:         5310
>Category:       c++
>Synopsis:       Wierd warnings about using (int)NULL
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 07 22:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     suckfish@ihug.co.nz
>Release:        3.0.3
>Organization:
>Environment:
Debian GNU Linux, i686.
Debian gcc package gcc-3.0-3.0.3-1
>Description:
The attached file, compiled with g++ -Wall generates:

temp.cc: In function `void bar()':
temp.cc:8: warning: passing NULL used for non-pointer argument passing 1 of 
   `void foo(int)'
temp.cc:8: warning: argument to non-pointer type `int' from NULL

I think the warning message is bogus.  The argument expression has been cast to an int, so the compiler should not warn about using it as an int argument.

If it is decided that the warning message from line 8 is in fact correct, then line 9 should also give a warning (using NULL as a long is just as silly as using NULL as an int).
>How-To-Repeat:
Compile attached file with g++ -Wall
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="temp.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="temp.cc"

Ly8gQ29tcGlsZSBhcyBDKysgd2l0aCAtV2FsbAojaW5jbHVkZSA8c3RkbGliLmg+Cgp2b2lkIGZv
byAoaW50KTsKdm9pZCBmb28gKGxvbmcpOwoKdm9pZCBiYXIoKQp7CiAgIGZvbyAoKGludClOVUxM
KTsKICAgZm9vICgobG9uZylOVUxMKTsKfQo=



More information about the Gcc-bugs mailing list