On Wed, Nov 4, 2009 at 1:24 AM, Norbert Wenzel
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.
Not sure what is causing the problem, do you have a reduced test-case we can see? Also, two things. 1) You *really* should be posting this to the Spirit mailing list instead, will get faster responses and from knowledgeable people. 2) You *really* should be using Spirit.Qi, not Spirit.Classic. Your grammar's will be much shorter, much faster, and much easier.