🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #240

Incorrect non-constness warning

#240
From: Jason Merrill
Date: Sun, 12 Apr 1992 06:43
28 lines
1365 bytes
The code

bool Class::isEqual(const Object& ob) const
{ return this == castdown(&ob); }

generates the warning

Class.c: In method `int  Class::isEqual (const class Object&)const ':
Class.c:188: warning: argument passing of non-`const *' pointer from `const *'

My guess is that this warning means either that &ob is not of const * type,
or that the return value of castdown(&ob) is not of const * type.

1) ob is of const type, so &ob should be of const * type.
2) castdown is defined in a macro for each class as

static classname* castdown(Object* p)		{ return (classname*)p; } \
static const classname* castdown(const Object* p) \
	{ return (const classname*)p; } \

So g++ should choose the const function, and thus return const * from it.
I'm not sure what's going wrong here, but something seems to be.

The pertinent code is in the NIHCL 3.0, files Object.h and Class.c.

--
Jason Merrill
jason@jarthur.claremont.edu
Technical Details
Message-ID: <1992Apr12.064310.16402@muddcs.claremont.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jason

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jason
From: jason@jarthur.claremont.edu (Jason Merrill)
Subject: Incorrect non-constness warning
Message-ID: <1992Apr12.064310.16402@muddcs.claremont.edu>
Sender: gnulists@ai.mit.edu
Organization: Harvey Mudd College
Distribution: gnu
Date: Sun, 12 Apr 1992 06:43:10 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 29