Skip to content

Clean up redundant defines and warning suppressions in coreclr/vm/common.h#130928

Open
AaronRobinsonMSFT wants to merge 2 commits into
dotnet:mainfrom
AaronRobinsonMSFT:clean_common
Open

Clean up redundant defines and warning suppressions in coreclr/vm/common.h#130928
AaronRobinsonMSFT wants to merge 2 commits into
dotnet:mainfrom
AaronRobinsonMSFT:clean_common

Conversation

@AaronRobinsonMSFT

@AaronRobinsonMSFT AaronRobinsonMSFT commented Jul 16, 2026

Copy link
Copy Markdown
Member

Removes redundant/stale preprocessor defines and a block of blanket MSVC warning suppressions from src/coreclr/vm/common.h, and cleans up dead USE_COM_CONTEXT_DEF / _CRT_DEPENDENCY_ defines from the debug/md/unwinder stdafx.h files.

Changes

  • vm/common.h: Remove the #pragma warning(disable:...) block. The meaningful ones (4201, 4100, 4127, 4245, 4291, 4505) are already applied globally in eng/native/configurecompiler.cmake; the rest are off-by-default warnings.
  • Stale defines: USE_COM_CONTEXT_DEF and _CRT_DEPENDENCY_ have no remaining references in src/coreclr and are removed.
  • gchelpers.cpp / olevariant.cpp: Fix the two call sites that relied on the removed C4238 (rvalue used as lvalue) suppression by introducing named locals. No functional/GC behavior change.

Note

This PR description was generated with the assistance of GitHub Copilot.

…mon.h

Remove stale USE_COM_CONTEXT_DEF and _CRT_DEPENDENCY_ defines (no longer
referenced) from vm/common.h and the debug/md/unwinder stdafx.h files, and
drop the blanket MSVC #pragma warning(disable:...) block from vm/common.h
since those suppressions are already applied globally in
eng/native/configurecompiler.cmake.

Fix the two call sites that relied on the removed C4238 (rvalue used as
lvalue) suppression by introducing named locals:
- AllocateObject in gchelpers.cpp
- OleVariant::ExtractWrappedObjectsFromArray in olevariant.cpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 19deab6e-8bcd-404b-957a-092862dc4014
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes stale/redundant preprocessor defines and per-header MSVC warning suppressions in CoreCLR’s vm/common.h, and updates the two affected call sites to avoid relying on MSVC warning C4238 suppression.

Changes:

  • Removes the _MSC_VER #pragma warning(...) suppression block and dead defines from src/coreclr/vm/common.h.
  • Removes unused USE_COM_CONTEXT_DEF / _CRT_DEPENDENCY_ defines from several stdafx.h files.
  • Adjusts two call sites (gchelpers.cpp, olevariant.cpp) to avoid taking addresses of temporaries / passing rvalues where an lvalue is required.
Show a summary per file
File Description
src/coreclr/vm/olevariant.cpp Introduces a named DECIMAL local before memcpyNoGCRefs to avoid C4238 (address-of-temporary) patterns.
src/coreclr/vm/gchelpers.cpp Introduces a named OBJECTREF local before converting to _UNCHECKED_OBJECTREF to avoid C4238 (rvalue used as lvalue) patterns.
src/coreclr/vm/common.h Removes stale defines and the header-local MSVC warning suppression block.
src/coreclr/unwinder/stdafx.h Removes USE_COM_CONTEXT_DEF define (no remaining references).
src/coreclr/md/ceefilegen/stdafx.h Removes _CRT_DEPENDENCY_ define (no remaining references).
src/coreclr/debug/ee/stdafx.h Removes USE_COM_CONTEXT_DEF define (no remaining references).
src/coreclr/debug/daccess/stdafx.h Removes USE_COM_CONTEXT_DEF define (no remaining references).

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 0

Comment thread src/coreclr/vm/olevariant.cpp Outdated
Comment thread src/coreclr/vm/olevariant.cpp Outdated
Co-authored-by: Jan Kotas <jkotas@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

Comment thread src/coreclr/vm/common.h
Comment on lines 17 to 22
#if defined(_DEBUG)
#define DEBUG_REGDISPLAY
#endif

#ifdef _MSC_VER

// These don't seem useful, so turning them off is no big deal
#pragma warning(disable:4201) // nameless struct/union
#pragma warning(disable:4512) // can't generate assignment constructor
#pragma warning(disable:4211) // nonstandard extension used (char name[0] in structs)
#pragma warning(disable:4268) // 'const' static/global data initialized with compiler generated default constructor fills the object with zeros
#pragma warning(disable:4238) // nonstandard extension used : class rvalue used as lvalue
#pragma warning(disable:4291) // no matching operator delete found
#pragma warning(disable:4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized

// Depending on the code base, you may want to not disable these
#pragma warning(disable:4245) // assigning signed / unsigned
#pragma warning(disable:4127) // conditional expression is constant
#pragma warning(disable:4100) // unreferenced formal parameter

#pragma warning(1:4189) // local variable initialized but not used

#ifndef DEBUG
#pragma warning(disable:4505) // unreferenced local function has been removed
#pragma warning(disable:4313) // 'format specifier' in format string conflicts with argument %d of type 'type'
#endif // !DEBUG

// CONSIDER put these back in
#pragma warning(disable:4063) // bad switch value for enum (only in Disasm.cpp)
#pragma warning(disable:4710) // function not inlined
#pragma warning(disable:4527) // user-defined destructor required
#pragma warning(disable:4513) // destructor could not be generated
#endif // _MSC_VER

#define _CRT_DEPENDENCY_ //this code depends on the crt file functions


#include <stdint.h>
#include <stddef.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants