Skip to content

Conversation

Rageking8
Copy link
Contributor

  • Add new example that generates C2154.
  • In the error index page, change *trait* to __underlying_type as it seems to be the only trait that can cause C2154 (also to ensure both instances of the C2154 error message are identical).
  • Remove link to Compiler Support for Type Traits as there is no mention of __underlying_type. In fact, across the entire repository, the only mention of __underlying_type is in this error topic.
  • Add links to enumeration and underlying_type.

Example

// C2154.cpp
// compile with: /c

struct S {};
enum E {};
enum class EC {};

__underlying_type(S) s;     // C2154
__underlying_type(int) i;   // C2154
__underlying_type(E) e;     // OK
__underlying_type(EC) ec;   // OK
Visual Studio 2022
C:\Test>cl /c C2154.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35217 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

C2154.cpp
C2154.cpp(8): error C2154: 'S': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'
C2154.cpp(9): error C2154: 'int': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'
Visual Studio 2026 Insiders
C:\Test>cl /c C2154.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35503 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

C2154.cpp
C2154.cpp(8): error C2154: 'S': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'
C2154.cpp(9): error C2154: 'int': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'

Copy link
Contributor

@Rageking8 : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

Copy link
Contributor

Learn Build status updates of commit 72be0ba:

✅ Validation status: passed

File Status Preview URL Details
docs/error-messages/compiler-errors-1/compiler-error-c2154.md ✅Succeeded
docs/error-messages/compiler-errors-1/compiler-errors-c2100-through-c2199.md ✅Succeeded

For more details, please refer to the build report.

Copy link
Contributor

PRMerger Results

Issue Description
File Change Percent This PR contains file(s) with more than 30% file change.

@v-regandowner
Copy link
Contributor

@TylerMSFT - Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged Tracking label for the PR review team label Sep 22, 2025
@v-dirichards v-dirichards assigned v-aa400 and v-dirichards and unassigned v-aa400 Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants