Clean up redundant defines and warning suppressions in coreclr/vm/common.h#130928
Open
AaronRobinsonMSFT wants to merge 2 commits into
Open
Clean up redundant defines and warning suppressions in coreclr/vm/common.h#130928AaronRobinsonMSFT wants to merge 2 commits into
AaronRobinsonMSFT wants to merge 2 commits into
Conversation
…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: 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. |
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
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 fromsrc/coreclr/vm/common.h. - Removes unused
USE_COM_CONTEXT_DEF/_CRT_DEPENDENCY_defines from severalstdafx.hfiles. - 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
jkotas
reviewed
Jul 16, 2026
jkotas
reviewed
Jul 16, 2026
Open
3 tasks
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes redundant/stale preprocessor defines and a block of blanket MSVC warning suppressions from
src/coreclr/vm/common.h, and cleans up deadUSE_COM_CONTEXT_DEF/_CRT_DEPENDENCY_defines from the debug/md/unwinderstdafx.hfiles.Changes
vm/common.h: Remove the#pragma warning(disable:...)block. The meaningful ones (4201, 4100, 4127, 4245, 4291, 4505) are already applied globally ineng/native/configurecompiler.cmake; the rest are off-by-default warnings.USE_COM_CONTEXT_DEFand_CRT_DEPENDENCY_have no remaining references insrc/coreclrand 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.