Skip to content

Reconsider assert(!"Message") usage in coreclr. #44132

Open
@sandreenko

Description

@sandreenko
  • There are at least 3 asserts that are always true, because of a forgotten ! before the message, when fixed they fail on some tests, see Fix asserts that were always true due to a missed neg. #44095, PTAL @tannergooding.

  • PORTABILITY_ASSERT(message) (108 usages) are quite confusing because they don't check a condition and fail always. They could be replaced by unreached or unimplemented methods, also this block looks pretty outdated:

    #if defined(TARGET_X86)
    // Finished ports - compile-time errors
    #define PORTABILITY_WARNING(message) NEED_TO_PORT_THIS_ONE(NEED_TO_PORT_THIS_ONE)
    #define PORTABILITY_ASSERT(message) NEED_TO_PORT_THIS_ONE(NEED_TO_PORT_THIS_ONE)
    #else
    // Ports in progress - run-time asserts only
    #define PORTABILITY_WARNING(message)
    #define PORTABILITY_ASSERT(message) _ASSERTE(false && (message))
    #endif

    are not other platforms finished now?
    PTAL @BruceForstall, @davidwrighton, you had a similar discussion about IMPL_LIMIT recently, do you have preferences about assert/unimplemented/unreached usages?

  • There are 6 usages of ASSERT(!"message") and 360 usages of ASSERT("message") with different defines, probably replace both with better debug only unreached("message")?

cc @dotnet/jit-contrib

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions