Skip to content

debugreturn.h should not macroize C++ keywords #67470

@GrabYourPitchforks

Description

@GrabYourPitchforks

The reserved keyword return is macroized in debugreturn.h:

#define return return

// 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions