hof icon indicating copy to clipboard operation
hof copied to clipboard

Boost failed with error C2892 when build with MSVC on windows

Open QuellaZhang opened this issue 5 years ago • 5 comments

Hi All,

We tried to build and run hof test for Boost with VS2017 Update 7 on Windows. It failed to build due to the error C2892. Could you please help take a look at this? Thank you!

Reproduce steps:

  1. git clone -c core.autocrlf=true --recursive https://github.com/boostorg/boost.git D:\Boost\src
  2. open a VS 2015 x86 command prompt and browse to D:\Boost\src
  3. .\bootstrap
  4. .\b2 headers variant=release --build-dir=..\out\x86rel address-model=32
  5. .\b2 variant=release --build-dir=..\out\x86rel address-model=32
  6. .\b2 -j4 variant=release --build-dir=..\out\x86rel libs\hof\test

Failures: libs\hof\test\lift.cpp(42): error C2892: a template cannot be a member of a local class libs\hof\test\lift.cpp(45): error C2892: a template cannot be a member of a local class libs\hof\test\lift.cpp(46): error C2892: a template cannot be a member of a local class libs\hof\test\lift.cpp(49): error C2892: a template cannot be a member of a local class libs\hof\test\lift.cpp(50): error C2892: a template cannot be a member of a local class

QuellaZhang avatar Sep 11 '18 03:09 QuellaZhang

So it looks like the workaround for MSVC no longer works. You can try disabling the workaround here by changing #if defined (_MSC_VER) to #if 0. If that works then the workaround is no longer needed for VS2017 Update 7, and we probably should update the #if to check the MSVC version.

I dont have access to windows right now to try this locally.

pfultz2 avatar Sep 11 '18 15:09 pfultz2

Thanks @pfultz2. I tried what you said and it works well on default mode. Maybe you can consider updating this.

QuellaZhang avatar Sep 12 '18 10:09 QuellaZhang

What is _MSC_VER set to for VS2017 Update 7?

pfultz2 avatar Sep 20 '18 16:09 pfultz2

You can use the compiler explorer to reproduce the error: https://godbolt.org/z/fEaqWx

erikzenker avatar Jan 10 '21 13:01 erikzenker

@pfultz2 I can confirm that the workaround for MSVC is not necessary anymore (see here https://godbolt.org/z/W8oEPG). So we should check the version of the MSVC.

erikzenker avatar Jan 10 '21 13:01 erikzenker