-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
Milestone
Description
The reserved keyword return
is macroized in debugreturn.h:
runtime/src/coreclr/inc/debugreturn.h
Line 25 in 3c3155d
#define return return |
runtime/src/coreclr/inc/debugreturn.h
Lines 93 to 102 in 3c3155d
// Unfortunately, the only way to make this work is to #define all return statements -- | |
// even the ones at global scope. This actually generates better code that appears. | |
// The call is dead, and does not appear in the generated code, even in a checked | |
// build. (And, in fastchecked, there is no penalty at all.) | |
// | |
#ifdef _MSC_VER | |
#define return if (0 && __ReturnOK::safe_to_return()) { } else return | |
#else // _MSC_VER | |
#define return for (;1;__ReturnOK::safe_to_return()) return | |
#endif // _MSC_VER |
This is preventing import of some STL headers, causing build failures in PRs such as #67464. Static analyzers like https://rules.sonarsource.com/cpp/RSPEC-5266 catch this as bad practice, and MSVC also flags this as an error.
Consider using a different name, such as CHECKED_RETURN
, instead of piggybacking on the reserved keyword return
.
AaronRobinsonMSFT