Skip to content

VS 16.8, C++20 and no conformance mode

Hi,

With the very latest Visual Studio 16.8 C++20 support implies conformance mode (/permissive-).

Starting in Visual Studio 2019 version 16.8, the /std:c++latest option implicitly sets the /permissive- option. It's required for C++20 Modules support. Perhaps your code doesn't need modules support but requires other features enabled under /std:c++latest. You can explicitly enable Microsoft extension support by using the /permissive option without the trailing dash.

I wanted to enable permissive mode per target to be able to upgrade to the latest so I added target_compile_options(my_target PUBLIC "/permissive") however this doesn't seem to have any effect on what parameters are passed to cl.exe.

See example repository.

I'm using CMake v3.18.4. Commands used to configure and build example repo:

cmake -S test/ -B test_build

cmake --build test_build/ --config Release --parallel --verbose

The output I get is:

p.ficzere@rapp-pw10-gpu52 /cygdrive/c/Temp
$ rm -fr ./test_build/ && cmake -S test/ -B test_build && cmake --build test_build/ --config Release --parallel --verbose
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.14393.
-- The C compiler identification is MSVC 19.28.29333.0
-- The CXX compiler identification is MSVC 19.28.29333.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Temp/test_build
Microsoft (R) Build Engine version 16.8.1+bd2ea1e3c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 12/11/2020 21:25:35.
     1>Project "C:\Temp\test_build\ALL_BUILD.vcxproj" on node 1 (default targets).
     1>Project "C:\Temp\test_build\ALL_BUILD.vcxproj" (1) is building "C:\Temp\test_build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
     2>PrepareForBuild:
         Creating directory "x64\Release\ZERO_CHECK\".
         Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\".
       InitializeBuildStatus:
         Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
       CustomBuild:
         Checking Build System
       FinalizeBuildStatus:
         Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
         Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
     2>Done Building Project "C:\Temp\test_build\ZERO_CHECK.vcxproj" (default targets).
     1>Project "C:\Temp\test_build\ALL_BUILD.vcxproj" (1) is building "C:\Temp\test_build\test.vcxproj" (3) on node 1 (default targets).
     3>PrepareForBuild:
         Creating directory "test.dir\Release\".
         Creating directory "C:\Temp\test_build\Release\".
         Creating directory "test.dir\Release\test.tlog\".
       InitializeBuildStatus:
         Creating "test.dir\Release\test.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
       CustomBuild:
         Building Custom Rule C:/Temp/test/CMakeLists.txt
       ClCompile:
         C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\CL.exe /c /nologo /W1 /WX- /diagnostics:column /O2 /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++latest /Fo"test.dir\Release\\" /Fd"test.dir\Release\vc142.pdb" /Gd /TP /errorReport:queue C:\Temp\test\test.cpp
         test.cpp
     3>C:\Temp\test\test.cpp(5,32): error C2440: 'initializing': cannot convert from 'const char [13]' to 'char *' [C:\Temp\test_build\test.vcxproj]
       C:\Temp\test\test.cpp(5,16): message : Conversion from string literal loses const qualifier (see /Zc:strictStrings) [C:\Temp\test_build\test.vcxproj]
     3>Done Building Project "C:\Temp\test_build\test.vcxproj" (default targets) -- FAILED.
     1>Done Building Project "C:\Temp\test_build\ALL_BUILD.vcxproj" (default targets) -- FAILED.

Build FAILED.

       "C:\Temp\test_build\ALL_BUILD.vcxproj" (default target) (1) ->
       "C:\Temp\test_build\test.vcxproj" (default target) (3) ->
       (ClCompile target) ->
         C:\Temp\test\test.cpp(5,32): error C2440: 'initializing': cannot convert from 'const char [13]' to 'char *' [C:\Temp\test_build\test.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.03

Could you please clarify whether this is an issue in CMake, Visual studio or I misunderstand something?

Thanks, Peter Ficzere

Edited by Péter Ficzere
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information