Boost.Spirit.Qi and Boost.Variant doesn't work together with NDEBUG on clang or gcc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Boost.Spirit.Qi and Boost.Variant doesn't work together with NDEBUG on clang or gcc

damien.buhl@lecbna.org

Hi Spirit developers ,

I've found an issue in Boost.Spirit.Qi when parsing a Variant with the bitwise-or operator, if I add the compile flag -DNDEBUG, a simple qi rule is not able to initialize a variant anymore with the parsed data.

I don't know if this issue already exists, I searched on the trac but couldn't find anything.

typedef boost::variant<int, bool, std::string> frame;

  rule<Iterator, frame()> r =
      int_
    | bool_
    | as_string[*char_]
  ;

The code to reproduce the bug is here : https://github.com/daminetreg/bug-boost-spirit-qi-ndebug/blob/master/ndebug_compilation.cpp

If I parse the texts, in order :  "this is a string", "42", "true", then I get :

Compiled without -DNDEBUG, it parses correctly :
http://melpon.org/wandbox/permlink/y3ueDkxbJYsYn7vs

$ ./without_ndebug
NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE this is a string
i 42
b 1

Once compiled with -DNDEBUG, it doesn't parse anything anymore and let the variant default-initialized:
http://melpon.org/wandbox/permlink/cgu20wphStlrJoMQ

$ ./with_ndebug
i 0
i 0
i 0

I can confirm the bug is not in Boost.Variant but somewhere else, because I can reproduce it exactly, using another Variant type (i.e. MapBox.Variant) : https://github.com/sauter-hq/boost-spirit-mapbox-variant.

I think it's not compiler related, because different versions of clang and gcc appears to produce the same result.

Cheers,
--
Damien Buhl

------------------------------------------------------------------------------

_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel