[Bug c++/31755] New: Clarify NULL pointer conversion to other types in initialiser
jg at jguk dot org
gcc-bugzilla@gcc.gnu.org
Sun Apr 29 13:50:00 GMT 2007
Could the warning message below be revised to include a warning that NULL will
evaluate to false or zero?
In addition, is there a way to add the member name which is being initialised
to the warning? The line numbers are not accurate too, so it needs some
inspection to figure out the members concerned.
$ g++ -Wall -o t main.cpp
main.cpp: In constructor ÂA::A()Â:
main.cpp:16: warning: converting to non-pointer type Âbool from NULL
main.cpp:16: warning: converting to non-pointer type Âint from NULL
main.cpp:16: warning: converting to non-pointer type Âunsigned int from NULL
Could it be revised to display something like this?
$ g++ -Wall -o t main.cpp
main.cpp: In constructor ÂA::A()Â:
main.cpp:16: warning: initialization of A::m_bool converts to non-pointer type
Âbool from NULL
main.cpp:16: warning: initialization of A::m_int converts to non-pointer type
Âint from NULL
main.cpp:16: warning: initialization of A::m_unit converts to non-pointer type
Âunsigned int from NULL
Example program:
=====================
// g++ -Wall -o t main.cpp
#include <string.h>
class A
{
public:
A();
bool m_bool;
int m_int;
unsigned int m_uint;
};
A::A()
: m_bool(NULL),
m_int(NULL),
m_uint(NULL)
{
}
int main()
{
}
--
Summary: Clarify NULL pointer conversion to other types in
initialiser
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jg at jguk dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31755
More information about the Gcc-bugs
mailing list