This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How do I avoid this warning?
- From: "Dave Williss" <dwilliss at microimages dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 18 Jul 2002 10:01:21 -0500
- Subject: How do I avoid this warning?
I get a lot of warnings of the type:
warning: choosing `FOO::operator BAR*()` over `FOO::operator const
BAR*()
for conversion from FRED to const BAR*
because conversion sequence for the argument is better
How do I code so that the conversion won't be better?
I was going to ask if there was an option to disable this warning, but I can
see a case where this really would be incorrect behavior. If the const
operator returns a pointer to internal data directly and the non-const has
to make a copy that the caller is expected to free, calling the non-const
method when the const was intended would give unexpected results (and leak
memory). This is just a hypothetical situation, but supports the need for
the warning.
So how do I force it to behave and call the correct method?
-- Dave Williss
------
Meddle not in the affairs of dragons,
for you are crunchy and taste good with catsup