Boost logo

Boost :

Subject: Re: [boost] [wave][function] Suppressing gcc-4.4.1 warnings
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-11-05 23:53:35

On Thu, Nov 5, 2009 at 7:17 AM, John Maddock <john_at_[hidden]> wrote:
> Looks like the new type-punning warnings from gcc-4.4.1 are false positives
> (but I'd like someone else to confirm that!).
> The fixes below illustrate how to suppress them simply by declaring a
> temporary variable.
> HTH, John.
> Index: boost/wave/util/flex_string.hpp
> ===================================================================
> --- boost/wave/util/flex_string.hpp     (revision 57230)
> +++ boost/wave/util/flex_string.hpp     (working copy)
> @@ -1211,7 +1211,10 @@
>    };
>    Storage& Data() const
> -    { return *reinterpret_cast<Storage*>(buf_); }
> +    {
> +       Storage* p = reinterpret_cast<Storage*>(buf_);
> +       return *p;
> +    }

What a terrible warning. You'd think reinterpret_cast<> would be
enough to tell the compiler to back off. And the 'fixed' code is no
better or worse. (I actually find the original version more
understandable - ie closer to the intent of the code.) And what if
the next version of the compiler recognizes the fixed code as bad as
well? At some point will it be 'you just can't do that'?
(P.S. can't you reinterpret_cast references as well? ie
reinterpret_cast<Storage &> ?)

Sigh. Anyhow, what I originally wanted to say about this whole
warnings business is

   "A journey of a thousand miles begins with a single step." (Confucius)

ie we just need to start fixing warnings and whittle it down one at a time.

And lastly, isn't gcc open source? Could someone add #pragma
push/pop/ignore etc or are they philosophically against that? Seems
hard/impossible to tweak warnings in gcc.


Boost list run by bdawes at, gregod at, cpdaniel at, john at