|
Boost Users : |
Subject: Re: [Boost-users] Problem with -Wall and Property Tree
From: José Tomás Tocino García (theom3ga_at_[hidden])
Date: 2010-06-08 11:04:06
2010/6/8 Sebastian Redl <sebastian.redl_at_[hidden]>
>
> On Tue, 8 Jun 2010 12:23:03 +0200, José Tomás Tocino García
> <theom3ga_at_[hidden]> wrote:
> > cout << myTree.get<float>("sonido.limite", 0.);
> >
> > If I compile using "g++ -o program testcase1.cpp -I." I get no errors,
> but
> > if I add "-Wall", I get:
> >
> > ./boost/property_tree/detail/ptree_implementation.hpp: In function int
> > main(int, char**):
> > ./boost/property_tree/detail/ptree_implementation.hpp:728: warning:
> > dereferencing pointer default_value does break strict-aliasing rules
> > /usr/include/boost/optional/optional.hpp:422: note: initialized from
> here
> >
> > What's the problem? It compiles and works properly, but it would be
> great
> > to
> > have a warning-free compilation output.
>
> That's really weird, and looks more like a compiler bug to me than a valid
> warning. For sure, 'default_value' is certainly not initialized within
> optional.hpp. But then, the strict-aliasing warnings are flow-sensitive and
> thus emitted during optimization, which means that GCC's internal view of
> the source could be quite seriously messed up by then.
>
> Do you get the warning if you explicitly type the default value correctly,
> i.e. use '0.f' instead of '0.'?
>
> Sebastian
>
If I use 0.f, I still get the error, but it disappears if I omit the default
value. Looks like disabling optimisation (in my code, -O2 was actually used)
also makes the error disappear.
I think that's what I'm going to do, wraping the call in a try...catch
block, so if the value does not exist, I'll manually asign it to the
variable.
Thanks for your answer.
-- José Tomás Tocino García
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net