boost::property_tree::info_parser breaks on spaces in value

后端 未结 1 570
南笙
南笙 2021-01-20 07:49

I am facing an issue where I have a configuration file and I parse it with boost::property_tree:info_parser.

I use this code to do the work:

struct _         


        
相关标签:
1条回答
  • 2021-01-20 08:27

    It was Undefined Behaviour, specifically

    The static initialization fiasco

    The manifestation here is quite subtle!

    Valgrind told me that info_parser::is_simple_data<char> is accessing a string freed. That string would be the local static. Both are being called from __run_exit_handlers() but not in any particular order! See the linked C++FAQ entry for explanations.

    Solution, don't depend on global statics with RAII:

    int main()
    {
        _Config Config;
        Config.Load();
    }
    

    is just fine, see it Live On Coliru

    0 讨论(0)
提交回复
热议问题