diff --git a/docs/_breadcrumb/toc.yml b/docs/_breadcrumb/toc.yml index 08c2231e264..efaed4b8a9e 100644 --- a/docs/_breadcrumb/toc.yml +++ b/docs/_breadcrumb/toc.yml @@ -1,3 +1,4 @@ +items: - name: Docs tocHref: / topicHref: / diff --git a/docs/assembler/toc.yml b/docs/assembler/toc.yml index ddda8b8fef5..8f8b923a9c3 100644 --- a/docs/assembler/toc.yml +++ b/docs/assembler/toc.yml @@ -1,3 +1,4 @@ +items: - name: Compiler intrinsics and assembly language href: ../intrinsics/index.yml - name: Compiler intrinsics diff --git a/docs/atl-mfc-shared/toc.yml b/docs/atl-mfc-shared/toc.yml index dbc065eaca8..39bdbdcbe94 100644 --- a/docs/atl-mfc-shared/toc.yml +++ b/docs/atl-mfc-shared/toc.yml @@ -1,3 +1,4 @@ +items: - name: ATL-MFC shared classes href: ../atl-mfc-shared/atl-mfc-shared-classes.md - name: ATL-MFC concepts diff --git a/docs/atl/toc.yml b/docs/atl/toc.yml index a980a764b53..931fbffd523 100644 --- a/docs/atl/toc.yml +++ b/docs/atl/toc.yml @@ -1,3 +1,4 @@ +items: - name: Active Template Library (ATL) href: atl-com-desktop-components.md - name: Active Template Library (ATL) concepts diff --git a/docs/build-insights/toc.yml b/docs/build-insights/toc.yml index 0c49fd52832..30f047a6e9d 100644 --- a/docs/build-insights/toc.yml +++ b/docs/build-insights/toc.yml @@ -1,3 +1,4 @@ +items: - name: "C++ Build Insights" href: ../build-insights/index.yml - name: "Get started with C++ Build Insights" diff --git a/docs/build/toc.yml b/docs/build/toc.yml index f9533249d4b..127c19fe656 100644 --- a/docs/build/toc.yml +++ b/docs/build/toc.yml @@ -1,3 +1,4 @@ +items: - name: Projects and build systems href: ../build/projects-and-build-systems-cpp.md - name: Visual Studio projects - C++ diff --git a/docs/c-language/toc.yml b/docs/c-language/toc.yml index 854cf0ed733..bdec148f7a9 100644 --- a/docs/c-language/toc.yml +++ b/docs/c-language/toc.yml @@ -1,3 +1,4 @@ +items: - name: C language documentation href: ../c-language/index.yml - name: C language reference diff --git a/docs/c-runtime-library/toc.yml b/docs/c-runtime-library/toc.yml index 722c04c1a67..fbcbac882ff 100644 --- a/docs/c-runtime-library/toc.yml +++ b/docs/c-runtime-library/toc.yml @@ -1,3 +1,4 @@ +items: - name: C runtime library (CRT) reference href: ../c-runtime-library/c-run-time-library-reference.md - name: CRT library features diff --git a/docs/code-quality/toc.yml b/docs/code-quality/toc.yml index 244f5c7f3ec..8b4267b424c 100644 --- a/docs/code-quality/toc.yml +++ b/docs/code-quality/toc.yml @@ -1,3 +1,4 @@ +items: - name: Code analysis documentation href: ../code-quality/index.yml - name: Overview diff --git a/docs/cpp/toc.yml b/docs/cpp/toc.yml index 83f0eeb0239..a41c3e256cc 100644 --- a/docs/cpp/toc.yml +++ b/docs/cpp/toc.yml @@ -1,3 +1,4 @@ +items: - name: C++ language documentation href: ../cpp/index.yml - name: C++ language reference @@ -69,9 +70,9 @@ href: ../cpp/void-cpp.md - name: bool href: ../cpp/bool-cpp.md - - name: false + - name: "false" href: ../cpp/false-cpp.md - - name: true + - name: "true" href: ../cpp/true-cpp.md - name: char, wchar_t, char8_t, char16_t, char32_t href: ../cpp/char-wchar-t-char16-t-char32-t.md @@ -419,8 +420,6 @@ href: ../cpp/special-member-functions.md - name: Static members href: ../cpp/static-members-cpp.md - - name: C++ classes as value types - href: ../cpp/value-types-modern-cpp.md - name: User-defined type conversions href: ../cpp/user-defined-type-conversions-cpp.md - name: Mutable data members @@ -481,8 +480,6 @@ href: ../cpp/how-to-create-and-use-weak-ptr-instances.md - name: "How to: Create and use CComPtr and CComQIPtr instances" href: ../cpp/how-to-create-and-use-ccomptr-and-ccomqiptr-instances.md - - name: Pimpl for compile-time encapsulation - href: ../cpp/pimpl-for-compile-time-encapsulation-modern-cpp.md - name: Exception handling in C++ items: - name: Exception handling in C++ diff --git a/docs/cppcx/toc.yml b/docs/cppcx/toc.yml index 4d5d0228392..d4171f81869 100644 --- a/docs/cppcx/toc.yml +++ b/docs/cppcx/toc.yml @@ -1,3 +1,4 @@ +items: - name: UWP development href: ../cppcx/universal-windows-apps-cpp.md - name: C++/CX language reference diff --git a/docs/cross-platform/toc.yml b/docs/cross-platform/toc.yml index af14bd391d1..4446b6541ff 100644 --- a/docs/cross-platform/toc.yml +++ b/docs/cross-platform/toc.yml @@ -1,3 +1,4 @@ +items: - name: Cross-platform mobile development with C++ href: ../cross-platform/index.yml - name: Overview diff --git a/docs/data/toc.yml b/docs/data/toc.yml index e53e0548b2c..aea9e6bb11e 100644 --- a/docs/data/toc.yml +++ b/docs/data/toc.yml @@ -1,3 +1,4 @@ +items: - name: Data access in Visual C++ href: ../data/data-access-in-cpp.md - name: Data access programming (MFC-ATL) diff --git a/docs/dotnet/toc.yml b/docs/dotnet/toc.yml index 37bc30df4bc..a6cb484b9c7 100644 --- a/docs/dotnet/toc.yml +++ b/docs/dotnet/toc.yml @@ -1,3 +1,4 @@ +items: - name: .NET programming with C++/CLI href: ../dotnet/dotnet-programming-with-cpp-cli-visual-cpp.md - name: "Walkthrough: Compile a C++/CLI program that targets the CLR" diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c2666.md b/docs/error-messages/compiler-errors-2/compiler-error-c2666.md index 4e4b87236a5..7307e34bb41 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c2666.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c2666.md @@ -1,7 +1,7 @@ --- description: "Learn more about: Compiler Error C2666" title: "Compiler Error C2666" -ms.date: "11/04/2016" +ms.date: 10/18/2021 f1_keywords: ["C2666"] helpviewer_keywords: ["C2666"] ms.assetid: 78364d15-c6eb-439a-9088-e04a0176692b @@ -30,6 +30,52 @@ int main() { } ``` +This error can be generated as a result of compiler conformance work that was done for Visual Studio 2019 version 16.1: + +- A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different. + +The following example demonstrates how compiler behavior changes in Visual Studio 2019 version 16.1 and later versions: + +```cpp +#include + +enum E : unsigned char { e }; + +int f(unsigned int) +{ + return 1; +} + +int f(unsigned char) +{ + return 2; +} + +struct A {}; +struct B : public A {}; + +int f(unsigned int, const B&) +{ + return 3; +} + +int f(unsigned char, const A&) +{ + return 4; +} + +int main() +{ + // Calls f(unsigned char) in 16.1 and later. Called f(unsigned int) in earlier versions. + // The conversion from 'E' to the fixed underlying type 'unsigned char' is better than the + // conversion from 'E' to the promoted type 'unsigned int'. + f(e); + + // Error C2666. This call is ambiguous, but previously called f(unsigned int, const B&). + f(e, B{}); +} +``` + This error can also be generated as a result of compiler conformance work that was done for Visual Studio .NET 2003: - binary operators and user-defined conversions to pointer types diff --git a/docs/error-messages/toc.yml b/docs/error-messages/toc.yml index 9597c9b39bd..2bb7407359e 100644 --- a/docs/error-messages/toc.yml +++ b/docs/error-messages/toc.yml @@ -1,3 +1,4 @@ +items: - name: C/C++ Compiler and build tools errors and warnings href: compiler-errors-1/c-cpp-build-errors.md - name: BSCMAKE errors and warnings diff --git a/docs/extensions/toc.yml b/docs/extensions/toc.yml index c865a10c743..5e19ed829dc 100644 --- a/docs/extensions/toc.yml +++ b/docs/extensions/toc.yml @@ -1,3 +1,4 @@ +items: - name: Component Extensions for .NET and UWP href: ../extensions/component-extensions-for-runtime-platforms.md - name: Tracking reference operator diff --git a/docs/get-started/breadcrumb/toc.yml b/docs/get-started/breadcrumb/toc.yml index fdc04e4ebb3..1185736d948 100644 --- a/docs/get-started/breadcrumb/toc.yml +++ b/docs/get-started/breadcrumb/toc.yml @@ -1,3 +1,4 @@ +items: - name: Docs tocHref: / topicHref: / diff --git a/docs/ide/toc.yml b/docs/ide/toc.yml index 54498e820e3..6a24a53a6bb 100644 --- a/docs/ide/toc.yml +++ b/docs/ide/toc.yml @@ -1,3 +1,4 @@ +items: - name: Read and write C++ code in Visual Studio expanded: true items: diff --git a/docs/intrinsics/toc.yml b/docs/intrinsics/toc.yml index e32b1d4e512..a6a4865d218 100644 --- a/docs/intrinsics/toc.yml +++ b/docs/intrinsics/toc.yml @@ -1,3 +1,4 @@ +items: - name: Compiler intrinsics and assembly language href: ../intrinsics/index.yml - name: Compiler intrinsics diff --git a/docs/linux/toc.yml b/docs/linux/toc.yml index a89016c2243..06e66952719 100644 --- a/docs/linux/toc.yml +++ b/docs/linux/toc.yml @@ -1,3 +1,4 @@ +items: - name: Linux with Visual Studio C++ documentation href: ../linux/index.yml - name: Download, install, and set up the Linux Development workload diff --git a/docs/mfc/toc.yml b/docs/mfc/toc.yml index 02b561d6969..b5010afabe1 100644 --- a/docs/mfc/toc.yml +++ b/docs/mfc/toc.yml @@ -1,3 +1,4 @@ +items: - name: MFC desktop applications href: mfc-desktop-applications.md - name: MFC concepts diff --git a/docs/overview/cpp-conformance-improvements.md b/docs/overview/cpp-conformance-improvements.md index b1de1b72097..907561ebe54 100644 --- a/docs/overview/cpp-conformance-improvements.md +++ b/docs/overview/cpp-conformance-improvements.md @@ -1,7 +1,7 @@ --- title: "C++ conformance improvements in Visual Studio 2019" description: "Microsoft C++ in Visual Studio is progressing toward full conformance with the C++20 language standard." -ms.date: 06/11/2021 +ms.date: 10/18/2021 ms.technology: "cpp-language" --- # C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2019 @@ -523,6 +523,58 @@ void f() { [P0329R4](https://wg21.link/p0329r4) (C++20) *Designated initialization* allows specific members to be selected in aggregate initialization by using the `Type t { .member = expr }` syntax. Requires **`/std:c++latest`** (or **`/std:c++20`** starting in Visual Studio 2019 version 16.11). +### Ranking of enum conversion to its fixed underlying type + +The compiler now ranks enum conversions according to [N4800](https://wg21.link/n4800) 11.3.3.2 Ranking implicit conversion sequences (4.2): + +- A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different. + +This conversion ranking wasn't implemented correctly before Visual Studio 2019 version 16.1. The conforming behavior may change overload resolution behavior or expose an ambiguity where one previously was not detected. + +This compiler behavior change applies to all **`/std`** modes and is both a source and binary breaking change. + +The following example demonstrates how compiler behavior changes in 16.1 and later versions: + +```cpp +#include + +enum E : unsigned char { e }; + +int f(unsigned int) +{ + return 1; +} + +int f(unsigned char) +{ + return 2; +} + +struct A {}; +struct B : public A {}; + +int f(unsigned int, const B&) +{ + return 3; +} + +int f(unsigned char, const A&) +{ + return 4; +} + +int main() +{ + // Calls f(unsigned char) in 16.1 and later. Called f(unsigned int) in earlier versions. + // The conversion from 'E' to the fixed underlying type 'unsigned char' is better than the + // conversion from 'E' to the promoted type 'unsigned int'. + f(e); + + // Error C2666. This call is ambiguous, but previously called f(unsigned int, const B&). + f(e, B{}); +} +``` + ### New and updated standard library functions (C++20) - `starts_with()` and `ends_with()` for `basic_string` and `basic_string_view`. @@ -2462,6 +2514,12 @@ struct S { }; ``` +## Conformance improvements in Visual Studio 2019 version 16.11 + +### `/std:c++20` compiler mode + +Starting in Visual Studio 2019 version 16.11, the compiler now supports the [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) compiler mode. Previously, C++20 features were available only in [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) mode in Visual Studio 2019. Features that originally required **`/std:c++latest`** mode now work in **`/std:c++20`** mode or later in the latest versions of Visual Studio. + ## See also [Microsoft C/C++ language conformance](visual-cpp-language-conformance.md) diff --git a/docs/overview/toc.yml b/docs/overview/toc.yml index b9a98c5c813..86ed81f17f4 100644 --- a/docs/overview/toc.yml +++ b/docs/overview/toc.yml @@ -1,3 +1,4 @@ +items: - name: Microsoft C/C++ in Visual Studio expanded: false items: diff --git a/docs/parallel/toc.yml b/docs/parallel/toc.yml index 216cb45722b..98a9fd0393a 100644 --- a/docs/parallel/toc.yml +++ b/docs/parallel/toc.yml @@ -1,3 +1,4 @@ +items: - name: Parallel programming in MSVC href: ../parallel/parallel-programming-in-visual-cpp.md - name: Auto-parallelization and auto-vectorization diff --git a/docs/porting/toc.yml b/docs/porting/toc.yml index a7b5fd478e3..f7492ec5269 100644 --- a/docs/porting/toc.yml +++ b/docs/porting/toc.yml @@ -1,3 +1,4 @@ +items: - name: Microsoft C++ Porting and Upgrade Guide href: ../porting/visual-cpp-porting-and-upgrading-guide.md - name: Upgrade projects from earlier versions diff --git a/docs/preprocessor/toc.yml b/docs/preprocessor/toc.yml index 1219c278cbc..a2121985ada 100644 --- a/docs/preprocessor/toc.yml +++ b/docs/preprocessor/toc.yml @@ -1,3 +1,4 @@ +items: - name: C/C++ preprocessor reference href: ../preprocessor/c-cpp-preprocessor-reference.md - name: Preprocessor diff --git a/docs/sanitizers/toc.yml b/docs/sanitizers/toc.yml index 42fc6f780ea..6ca9012f81a 100644 --- a/docs/sanitizers/toc.yml +++ b/docs/sanitizers/toc.yml @@ -1,3 +1,4 @@ +items: - name: "Code Sanitizers" href: ../sanitizers/index.yml - name: "AddressSanitizer" diff --git a/docs/standard-library/toc.yml b/docs/standard-library/toc.yml index 10ef23ae748..e312918bfcf 100644 --- a/docs/standard-library/toc.yml +++ b/docs/standard-library/toc.yml @@ -1,3 +1,4 @@ +items: - name: C++ Standard Library reference href: cpp-standard-library-reference.md - name: C++ Standard Library header files diff --git a/docs/text/toc.yml b/docs/text/toc.yml index f53a1e36a3c..ee0b2b3066a 100644 --- a/docs/text/toc.yml +++ b/docs/text/toc.yml @@ -1,3 +1,4 @@ +items: - name: Text and strings in MSVC href: ../text/text-and-strings-in-visual-cpp.md - name: Unicode and MBCS diff --git a/docs/windows/toc.yml b/docs/windows/toc.yml index 0b2d35565f1..40174d40848 100644 --- a/docs/windows/toc.yml +++ b/docs/windows/toc.yml @@ -1,3 +1,4 @@ +items: - name: Overview of Windows programming in C++ href: ../windows/overview-of-windows-programming-in-cpp.md - name: Desktop Applications in C++