https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64431
Bug ID: 64431 Summary: "-Wignored-qualifiers" warning gives misleading position in code Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rutsky.vladimir at gmail dot com "type qualifiers ignored on function return type" warning doesn't point in "const" that is being ignored, but instead it points to function arguments or function qualifiers. Consider following example: $ cat ignored_qualifiers.cpp struct C { const int f1(); const int f2(float); const int f3(char *, int); const int f4() volatile const; const int f5() const volatile; }; const int f6(); const int f7(float); const int f8(char *, int); $ g++-4.9 -c -Wignored-qualifiers ignored_qualifiers.cpp ignored_qualifiers.cpp:3:18: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f1(); ^ ignored_qualifiers.cpp:4:23: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f2(float); ^ ignored_qualifiers.cpp:5:29: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f3(char *, int); ^ ignored_qualifiers.cpp:6:29: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f4() volatile const; ^ ignored_qualifiers.cpp:7:26: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f5() const volatile; ^ ignored_qualifiers.cpp:10:14: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f6(); ^ ignored_qualifiers.cpp:11:19: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f7(float); ^ ignored_qualifiers.cpp:12:25: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f8(char *, int); ^ Expected behavior: the warning should point on "const" in the return value of a funtion. For example: ignored_qualifiers.cpp:7:26: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] const int f5() const volatile; ^ $ g++-4.9 --version g++-4.9 (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.