Bug#506331: g++-4.3: Misleading warning claims to ignore spurious qualifiers on return type
Package: g++-4.3
Version: 4.3.2-1
Severity: minor
Put the following ridiculous code in a .cpp file: <text>
struct Base { virtual const int stupid() = 0; };
struct Derived : public Base { virtual int stupid() { return 1; } };
</text> and run the compiler on it, with warnings. I get: <quote>
$ g++ -O2 -Wall -Wextra -o spurious.o -c spurious.cpp
spurious.cpp:1: warning: type qualifiers ignored on function return type
spurious.cpp:2: error: conflicting return type specified for 'virtual int Derived::stupid()'
spurious.cpp:1: error: overriding 'virtual const int Base::stupid()'
make: *** [spurious.o] Error 1
</quote>
Observe that the warning claims to ignore the spurious const.
However, the error reveals that it was not ignored.
Had it been ignored, the over-ride's return would have matched.
The warning should say
warning: spurious type qualifiers on function return type
or something similar: it should not claim to ignore the type qualifier.
The obvious fix is, of course, to fix the base class: however, if that
is in a library not under my control, this isn't a practical option
when I come to sub-class it. I am consequently obliged to duplicate
the spurious type qualifier and, hence, get even more warnings about
it :-(
Priority is negligible, of course.
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.ISO-8859-15, LC_CTYPE=en_GB.ISO-8859-15 (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash
Versions of packages g++-4.3 depends on:
ii gcc-4.3 4.3.2-1 The GNU C compiler
ii gcc-4.3-base 4.3.2-1 The GNU Compiler Collection (base
ii libc6 2.7-16 GNU C Library: Shared libraries
ii libgmp3c2 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii libmpfr1ldbl 2.3.1.dfsg.1-2 multiple precision floating-point
ii libstdc++6-4.3-dev 4.3.2-1 The GNU Standard C++ Library v3 (d
g++-4.3 recommends no packages.
Versions of packages g++-4.3 suggests:
pn g++-4.3-multilib <none> (no description available)
ii gcc-4.3-doc 4.3.2.nf1-1 documentation for the GNU compiler
pn libstdc++6-4.3-dbg <none> (no description available)
-- no debconf information
Reply to: