Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55017

iassert/tassert evaluate arguments when untriggered

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Service Arch 2021-03-08, Service Arch 2021-03-22

      The iassert and tassert macros immediately expand all their arguments to a C++ function call expression. The called functions (there are several overloads possible) take nontrivial objects like std::string msg and SourceLocationHolder loc.

      Another consequence is that the condition is not evaluated in an if condition's bool context, which causes objects with explicit operator bool conversions to be rejected from iassert and uassert where they would not be rejected from the other asserts.
      (see SERVER-54836).

      An assertion has to be nearly free if the condition passes.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: