最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

boost spirit qi - ASAN stack-use-after-scope finding - when using parser with wrapped rule + auto keyword - Stack Overflow

programmeradmin1浏览0评论

complex but perfectly working grammar

my_grammar<It> grammar;

Test

using grammar direct --> NO ASAN finding

ok = qi::phrase_parse( f, l, qi::eps > grammar > qi::eoi, Skipper{}, v );

using a grammar "wrapper" --> ASAN Finding: stack-use-after-scope

auto grammar_wrapper = qi::eps > grammar > qi::eoi;

ok = qi::phrase_parse( f, l, grammar_wrapper, Skipper{}, v );

i have a problem to understand what type auto grammar_wrapper gets and why this type leads to an stack-user-after-scope

complex but perfectly working grammar

my_grammar<It> grammar;

Test

using grammar direct --> NO ASAN finding

ok = qi::phrase_parse( f, l, qi::eps > grammar > qi::eoi, Skipper{}, v );

using a grammar "wrapper" --> ASAN Finding: stack-use-after-scope

auto grammar_wrapper = qi::eps > grammar > qi::eoi;

ok = qi::phrase_parse( f, l, grammar_wrapper, Skipper{}, v );

i have a problem to understand what type auto grammar_wrapper gets and why this type leads to an stack-user-after-scope

Share Improve this question asked Mar 13 at 16:27 llmllm 7496 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

So... don't use the auto keyword.

If you must, combat dangling references by doing a boost::proto::deep_copy of the parser expressions involved. There's a convenient short-hand in recent versions of Spirit Qi: qi::copy:

auto grammar_wrapper = qi::copy ( qi::eps > grammar > qi::eoi );

Background:

  • Assigning parsers to auto variables
  • boost spirit V2 qi bug associated with optimization level
  • spirit::qi: Combining parser_factory fails
  • Boost Spirit Qi crashes for memory violation

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论