Issue 203643
Summary LIBC++, CLANG 15.20, stable_partition() does meet the ISO C++ requirements of only calling the predicate N times for low memory situations
Labels clang, libc++
Assignees
Reporter sjhowe888
    This is an instrumented code investigation into stable_partition. I have tested out Microsoft's, GCC's & CLANG's libraries of stable_partition(). 1 million items are added to a vector, randomly (using a homebrew random generator. This is for 64-bit C++ compilers, all the latest version.

stable_partition() is called with a suitable predicate. Now the ISO C++ requirements is that the predicate is called no more than 1 million times (as many as the number of items beign partitioned). stable_partition() can be run with enough memory for a buffer or without a buffer. Either way, the number of calls to the predicate should not change.

If the code is compiled with NOBUFFER defined => then the replacement operator new, nothrow is in operation and will starve memory being allocated for a buffer. If the code is compiled with NOBUFFER undefined or commented out => then a buffer is allocated.

When run, I see for the 6 situations:

Microsoft, buffered: Compare Count = 1000000
Microsoft, unbuffered: Compare Count = 1000000
GCC, buffered: Compare Count = 1000000
GCC, unbuffered: Compare Count = 1000000
CLANG, buffered: Compare Count = 1000000
CLANG, unbuffered: Compare Count = 1052964

See here for code link:
https://www.linkedin.com/pulse/clangs-stablepartition-1520-fails-iso-c-requirements-under-howe-dqvbe/
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to