Hi,
the following drives my mad:
---8<---
class CommandLineOptions {
public:
CommandLineOptions( int argc, char** argv );
bool option( const std::string& arg ) const;
...
private:
po::options_description generic_options;
po::options_description hidden_options;
po::options_description usage_options;
po::options_description cmdline_options;
po::positional_options_description pos_options;
po::variables_map vm;
};
--->8---
---8<---
bool CommandLineOptions::option( const std::string& arg ) const
{
return vm.count( arg );
}
--->8---
int main( int argc, char **argv )
{
try {
CommandLineOptions cmdline( argc, argv );
running using gdb (on return of main()):
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6f826c0 (LWP 16599)]
0x08051cb2 in std::_Rb_treestd::string, std::lessstd::string,
std::allocatorstd::string >::_S_right (__x=0x11) at
/usr/include/c++/4.2/bits/stl_tree.h:510
510 { return static_cast<_Link_type>(__x->_M_right); }
(gdb) bt
#0 0x08051cb2 in std::_Rb_treestd::string, std::lessstd::string,
std::allocatorstd::string >::_S_right (__x=0x11) at
/usr/include/c++/4.2/bits/stl_tree.h:510
#1 0x0805291d in std::_Rb_treestd::string, std::lessstd::string,
std::allocatorstd::string >::_M_erase (this=0xbfb95e48, __x=0x11) at
/usr/include/c++/4.2/bits/stl_tree.h:1323
#2 0x0805292c in std::_Rb_treestd::string, std::lessstd::string,
std::allocatorstd::string >::_M_erase (this=0xbfb95e48, __x=0x80c61b0)
at /usr/include/c++/4.2/bits/stl_tree.h:1323
#3 0x0805297b in ~_Rb_tree (this=0xbfb95e48) at
/usr/include/c++/4.2/bits/stl_tree.h:592
#4 0x080529cb in ~set (this=0xbfb95e48) at
/usr/include/c++/4.2/bits/stl_set.h:94
#5 0x08052b83 in ~variables_map (this=0xbfb95e28)
at /usr/local/include/boost/program_options/variables_map.hpp:139
#6 0x0805316d in ~CommandLineOptions (this=0xbfb95cac) at
src/eda/workbench/CommandLineOptions.hpp:23
#7 0x080515c3 in main (argc=1, argv=0xbfb961c4) at
src/eda/workbench/main.cpp:75
writing main() as:
---8<---
int main( int argc, char **argv )
{
try {
CommandLineOptions cmdline( argc, argv );
if (cmdline.option( "version" )) {
std::cout << ...
}
running using gdb:
Starting program: /home/opetzold/Projects/cpp/eda2/eda -v
...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6f716c0 (LWP 16883)]
0x08051d7e in std::_Rb_tree,
std::_Select1st >, std::lessstd::string,
std::allocator > >::_S_right (__x=0xb0012)
at /usr/include/c++/4.2/bits/stl_tree.h:510
510 { return static_cast<_Link_type>(__x->_M_right); }
(gdb) bt
#0 0x08051d7e in std::_Rb_tree,
std::_Select1st >, std::lessstd::string,
std::allocator > >::_S_right (__x=0xb0012)
at /usr/include/c++/4.2/bits/stl_tree.h:510
#1 0x08052b9f in std::_Rb_tree,
std::_Select1st >, std::lessstd::string,
std::allocator > >::_M_erase (
this=0xbfe2c0a8, __x=0xb0012) at
/usr/include/c++/4.2/bits/stl_tree.h:1323
#2 0x08052bae in std::_Rb_tree,
std::_Select1st >, std::lessstd::string,
std::allocator > >::_M_erase (
this=0xbfe2c0a8, __x=0xb6fceb2c) at
/usr/include/c++/4.2/bits/stl_tree.h:1323
#3 0x08052bfd in ~_Rb_tree (this=0xbfe2c0a8) at
/usr/include/c++/4.2/bits/stl_tree.h:592
#4 0x08052c4d in ~map (this=0xbfe2c0a8) at
/usr/include/c++/4.2/bits/stl_map.h:94
#5 0x08052cb6 in ~variables_map (this=0xbfe2c0a0)
at /usr/local/include/boost/program_options/variables_map.hpp:139
#6 0x0805327f in ~CommandLineOptions (this=0xbfe2bf24) at
src/eda/workbench/CommandLineOptions.hpp:23
#7 0x0805170a in main (argc=2, argv=0xbfe2c444) at
src/eda/workbench/main.cpp:75
Each time it crash in ~variables_map. Is it a bug??
I'm using gcc-Version 4.2.3 20080114 (prerelease) (Debian 4.2.2-7)
Thanks,
Olaf