Search

Failed to compile program using boost::program_options and lambda expression by jensa79

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 720670
Opened: 1/25/2012 12:53:57 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Hi,

compiling the following program fails with the error message:
Error 1 error C2871: 'validators' : a namespace with this name does not exist
Error 2 error C2871: 'program_options' : a namespace with this name does not exist

#include <boost/program_options.hpp>


template<typename T> void f(T t) {}


void g()
{
using namespace boost::program_options;


// each of the following lines produces the error:
// Error 1 error C2871: 'validators' : a namespace with this name does not exist
// Error 2 error C2871: 'program_options' : a namespace with this name does not exist


f([]() {} );
auto x = []() {};
}

The same source code compiles fine with gcc and I don't see any reason for the error, so I suspect a compiler problem.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Install boost 1.45 and compile file test.cpp in appended project.
For easier reproduction, I have also created a preprocessed file containing all the source. This file is called test_pp.cpp and also included in the project.

Product Language

English

Operating System

Windows 7

Operating System Language

German

Actual results

Compile error:
Error 1 error C2871: 'validators' : a namespace with this name does not exist
Error 2 error C2871: 'program_options' : a namespace with this name does not exist

Expected results

Compiles without error
File Attachments
File Name Submitted By Submitted On File Size  
program_options_and_lambda.zip 1/25/2012 244 KB
Sign in to post a comment.
Posted by Microsoft on 2/1/2012 at 3:55 PM
Hello,

Thank you for reporting this bug. We've made sure that this bug is fixed in the current in-progress release of Visual Studio. Next major release of VS will have the fix.

In the meantime, you workaround the bug by moving up the using namespace statement into global scope:
using namespace boost::program_options;
template<typename T> void f(T t) {}

void g()
{
// using namespace boost::program_options;

f([]() {} );
auto x = []() {};
}

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by MS-Moderator07 [Feedback Moderator] on 1/25/2012 at 7:39 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/25/2012 at 1:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.