C++20 Features in Visual Studio 2019 versions 16.7 and 16.8

Avatar

Daniel

What’s New

We have continued our efforts to implement C++20 in the MSVC toolset, with noteworthy progress being made in VS (Visual Studio) 2019 v16.7 and VS 2019 v16.8. This blog post lists the features implemented since the C++20 Features and Fixes in VS 2019 16.1 through 16.6 blog post.

This blog post will specifically focus on language features implemented in the MSVC compiler (cl.exe). The changelog for conformance progress for the STL is tracked in the Standard Library changelog in the Microsoft STL GitHub repo.

Some of the features covered were already highlighted in the announcements made at CppCon 2020 in September related to the VS 2019 v16.8 Preview 3 release.

As a reminder, the /std:c++17 and /std:c++latest compiler options are necessary to use C++17 and C++20 features, respectively. 

 

VS 2019 v16.7

C++20 Language Feature Support

  • Implemented P1009R2 Array size deduction in new-expressions  
  • Implemented P0722R3 Efficient sized delete for variable sized classes 
  • Implemented P1094R2 Nested inline namespaces 
  • Implemented P1331R2 Permitting trivial default initialization in constexpr contexts 
  • Implemented P1816R0 CTAD for aggregates 
  • Implemented P0388R4 Permit conversions to arrays of unknown bound 
  • Implemented P1452R2 On the non-uniform semantics of return-type-requirements 
  • Implemented P1152R4 Deprecating volatile 
  • Implemented P1814R0 CTAD for alias templates 
  • Implemented P1972R0 US105 Check satisfaction of constraints for non-templates… 
  • Implemented P1980R0 CA096: Declaration matching for non-dependent requires-clauses 
  • Implemented P0528R3 Atomic compare-and-exchange with padding bits 
  • Implemented P1358R0 Type completeness and derived-to-base pointer conversions 
  • Implemented P0466R5 Layout-Compatibility and Pointer-Interconvertibility Traits 
  • Implemented P2107R0 US064 Copy semantics of coroutine parameters 
  • Implemented P2107R0 US052 Non-executed return statements in coroutines 
  • Implemented P2103R0 Allow “import” inside linkage-specifications [dcl.link] 
  • Implemented P2085R0 Consistent defaulted comparisons 
  • Implemented CWG 2280 Matching a usual deallocation function with placement new 
  • Implemented CWG 2382 Array allocation overhead for non-allocating placement new 
  • Implemented CWG 2441 Inline function parameters 
  • Implemented CWG 2282 Consistency with mismatched aligned/non-over-aligned allocation/deallocation functions 
  • Implemented US212 Converting from T* to bool should be considered narrowing 

 

VS 2019 v16.8

C++20 Language Feature Support

  • Implemented P1103R3 Modules 
  • Implemented P0912R5 Coroutines 
  • Implemented P1286R2 Contra CWG DR1778 
  • Implemented P0315R4 Allowing lambdas in unevaluated contexts 
  • Implemented P0960R3 Allow initializing aggregates from a parenthesized list of values 
  • Implemented P0848R3 Conditionally trivial special member functions 
  • Implemented P1811R0 Relaxing redefinition restrictions for re-exportation robustness 
  • Implemented P1766R1 Mitigating minor modules maladies 
  • Implemented P1975R0 Fixing the wording of parenthesized aggregate-initialization 
  • Implemented P1874R1 Dynamic Initialization Order of Non-Local Variables in Modules 

 

Two of the major features of C++20, Modules and Coroutines, are now feature-complete in the MSVC toolset and are now implied by the /std:c++latest compiler switch.  

Strict conformance mode (/permissive-) and /std:c++latest

As a prerequisite for Modules support, `/permissive-` is now enabled when /std:c++latest is specifiedSee /permissive- documentation regarding compiling code under `/permissive-`. 

For code that previously compiled under /std:c++latest and requires non-conformant compiler behaviors, `/permissive` may be specified to turn off strict conformance mode in the compiler and must appear after /std:c++latest in the command line argument list.  

However, specifying `/permissive` will result in an error if Modules usage is encountered: 

error C1214: Modules conflict with non-standard behavior requested via ‘[option]’

Where the most common values for [option] are: 

  • `/Zc:twoPhase` : Two Phase name lookup (`/Zc:twoPhase`) is required for C++20 Modules and implied by `/permissive-`See also [/Zc:twoPhase documentation](https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase?view=vs-2019).  
  • `/Zc:hiddenFriend` : Standard hidden friend name lookup rules are required for C++20 Modules and implied by `/permissive-`.  
  • `/Zc:preprocessor` : Use of the conformant preprocessor (/Zc:preprocessor) is required for C++20 header unit usage and creation onlyNamed Modules do not require this option. See also /Zc:preprocessor documentation](https://docs.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=vs-2019 

More Information

For Visual Studio changes (beyond the C++ toolset) and download links, see the VS Release Notes and VS Preview Release Notes. You can report bugs through Developer Community, and you can also report STL bugs via microsoft/STL GitHub issues.

 

 

5 comments

Leave a comment