(Potential bug) Useless warning that shouldn't exist?

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jul 11 23:27:00 GMT 2013

On 11 July 2013 12:33, Alec Teal <a.teal@warwick.ac.uk> wrote:
> Hey guys,
> I'm really not sure what's wrong with this, I think it may be a bug but I am
> not sure. Hence posting it here first. These are from a shared library, that
> compiles fine with -Wall -Wextra, the header file is available to things
> that use the library. Particularly this has nothing to do with a  function,
> so why is it talking of a return type of a function?
> Header file:
> namespace sr {
> class Framebuffer;
> class Depthbuffer {
> public:
> *static const float INFINITY;*<--this line is what the warning is referring
> to.
> ...
> Implementation file:
> namespace sr {
> const float Depthbuffer::INFINITY = 1.0f;
> ....
> However when compiling a program that uses the library:
> if ! g++ -Isrc -MM src/Renderer.cpp >> build/Renderer.o.d ; then rm
> build/Renderer.o.d ; exit 1 ; fi
> g++ -Wall -Wextra -g -O0 -std=c++0x -gdwarf-2 -Wno-write-strings -I../libsr
> -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-release-2.8
> -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__
> -pthread -Isrc -c src/Renderer.cpp -o build/Renderer.o
> In file included from ./libsr/libsr.h:12:0,
>                  from src/Renderer.h:11,
>                  from src/Renderer.cpp:8:
> ./libsr/Framebuffer.h:17:21: warning: type qualifiers ignored on function
> return type [-Wignored-qualifiers]
> The line it doesn't like is the one in bold, static const float INFINITY;
> What is GCC warning me about? What's wrong?
> GCC 4.7.3

That line is not a function, so there shouldn't be a warning about
"function return type" -- are you sure that's the line it's referring
too?  Is INFINITY a macro defined in some header so that you're not
ompiling what you think you are?

Please provide a complete reproducable example, not snippets of code
with "..." that noone else can test.

More information about the Gcc-help mailing list