buffer overflow with boost::program_options

1

I have a problem using boost:program_options

this simple program, copy-pasted from boosts' documentation :

#include <boost/program_options.hpp>

int main( int argc, char** argv )
{

    namespace po = boost::program_options;

    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "produce help message")
        ("compression", po::value<int>(), "set compression level")
        ;
    return 0;
}

fails with a buffer overflow.

I have activated the "buffer security switch", and when I run it I get an "unknown exception (0xc0000409)" when I step over the line desc.add_options()...

I use Visual Studio 2005 and boost 1.43.0.

By the way it does run if I deactivate the switch but I don't feel comfortable doing so... unless it's possible to deactivate it locally.

So do you have a solution to this problem?

EDIT I found the problem I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library.

c++
visual-c++
boost
boost-program-options
asked on Stack Overflow Jun 15, 2010 by f4. • edited Jun 15, 2010 by f4.

2 Answers

1

It works in 2010. Was about to try in 2005 but realized I don't have 1.43 compiled in that environment.

answered on Stack Overflow Jun 15, 2010 by Crazy Eddie
0

I found the problem I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library since I changed the runtime library to Multithread DLL.

answered on Stack Overflow Jun 15, 2010 by f4.

User contributions licensed under CC BY-SA 3.0