$ cat pointless_volatile.c
volatile double limit_precision(double v) {
volatile double x = v;
return x;
}
$ gcc -Wall -c pointless_volatile.c
pointless_volatile.c:1: warning: type qualifiers ignored on function return
type
$ g++ -Wall -c pointless_volatile.c
$ g++ -Wall -W -pedantic -c pointless_volatile.c
$
This is strange, because the reasons for giving a warning are good in C++ as
they are good in C. See Section 3.10 of the C++ standard:
Point 6: The result of calling a function that does not return
a reference is an rvalue. User defined operators are functions, and
whether such operators expect or yield lvalues is determined by their
parameter and return types.
Point 9: Class rvalues can have cv-qualified types; non-class
rvalues always have cv-unqualified types. Rvalues shall always have
complete types or the void type; in addition to these types, lvalues
can also have incomplete types.
--
Summary: g++ misses a warning that gcc, instead, gives
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bagnara at cs dot unipr dot it
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24273