This is an archive of the discontinued LLVM Phabricator instance.

[libc++] [LIBCXX-DEBUG-FIXME] Our `__debug_less` breaks some complexity guarantees.
ClosedPublic

Authored by Quuxplusone on Apr 30 2021, 4:57 PM.

Details

Summary
`__debug_less` ends up running the comparator up-to-twice per comparison,
because whenever `(x < y)` it goes on to verify that `!(y < x)`.
This breaks the strict "Complexity" guarantees of algorithms like
`inplace_merge`, which we test in the test suite. So, just skip the
complexity assertions in debug mode.

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Apr 30 2021, 4:57 PM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptApr 30 2021, 4:57 PM

poke buildkite

ldionne accepted this revision.May 5 2021, 10:57 AM

LGTM, but please add a note in libcxx/docs/DesignDocs/DebugMode.rst that we don't necessarily respect complexity guarantees under the debug mode, which isn't obvious (but it makes sense when you think about it).

This revision is now accepted and ready to land.May 5 2021, 10:57 AM