http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44811

David Piepgrass <dpiepgrass at mentoreng dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dpiepgrass at mentoreng dot
                   |                            |com

--- Comment #4 from David Piepgrass <dpiepgrass at mentoreng dot com> 
2012-04-26 18:02:34 UTC ---
What makes warnings like this really irritating is that templates get
instantiated more than once. I'm getting about two dozen of these warnings from
just two lines of template code, since the template is instantiated for many
integer values. And that's just from one cpp file; other cpp files give a
separate set of warnings (I'd consider using extern template, except that I
have to target MSVC9 too.)

Actually, GCC currently gives many thousand warnings for my project: it seems
nearly half of them come from these left/right shift warnings, and nearly half
also come from a couple dozen member functions of the form "Foo Foo() const {
... }" that my code contains, which never bothered MSVC.

The documentation of the diagnostic pragma
(http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Diagnostic-Pragmas.html) doesn't
say how to disable all warnings... should this work?

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-w"
    template<int N> uint64_t shift(uint64_t b) {
        if (N > 0)
            return b << N;
        else
            return b >> -N;
    }
    #pragma GCC diagnostic pop

It doesn't work for me, but it may just be my older GCC (4.4.3 for Google
Android). 4.4.3 complains about not supporting push/pop, but it doesn't
complain about -w even though it does not actually suppress any warnings.

Could I perhaps disable all warnings by default, and then use a pragma to
re-enable all warnings when the .cpp is reached?

Reply via email to