Boost logo

Boost Users :

Subject: [Boost-users] [Spirit] [bind] Compiler warning dependent on number of rules?
From: Norbert Wenzel (n_wenzel_at_[hidden])
Date: 2009-11-04 03:24:52


Hello,

I'm currently parsing some data using Spirit together with boost::bind
to set the callbacks for Spirit. In release build I get a compiler (gcc
4.4.1) warning from bind:
warning: dereferencing pointer ‘val’ does break strict-aliasing rules

I was able to find the lines causing this problem by commenting them
out, rebuilding and the error got away. The strange thing is, that when
I copy some other parsing rules, that previously compiled without any
warning, I get the same warning again.

When trying to create a simple example to post here, it seemed that the
actual parsing code (that is the only code that uses boost::bind) was
exchangeable. It was the number of options in the parsing rule that
caused the warning to appear (which I really do not understand).

The parsing rule looks like this:

parse(someString.c_str(),
(
*(
str_p('+') >> str_p('(') >> real_p[boost::bind(&Object::func_param,
boost::ref(m_curObmect), _1)] >> str_p(')') |
str_p('+')[boost::bind(&Object::func, boost::ref(m_curObject), _1)] /*|

str_p('+') >> str_p('(') >> real_p[boost::bind(&Object::func_param,
boost::ref(m_curObmect), _1)] >> str_p(')') |
str_p('+')[boost::bind(&Object::func, boost::ref(m_curObject), _1)]
[... to be repeated ...] */

)
)
,
space_p).full;

The goal is to find either "+" or "+(double)", which works as expected.
causesThe signatures of the Object functions are
Object::func_param(double param); and
Object::func(char);

The rule can be copied 7 times, leading to 14 options, without any
warning. If I add one 8th copy of these lines, or if I just add a 15th
option (independent of the actual line I copy) I get the warning again.

My system is an Ubuntu Karmic 64bit machine, using gcc 4.4.1, boost 1.39
headers and simply including "boost/spirit.hpp", which means I get the
deprecation warning for that file at the moment.

I'd be thankful for any suggestions, since for now, I do not even know
where to look further. I do not have any idea what might cause this warning.

thanks,
Norbert




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