boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
96 stars 116 forks source link

flat_multimap::emplace not sorting elements under GCC #269

Closed OFFTKP closed 1 month ago

OFFTKP commented 3 months ago

Hello!

I have attached a code snippet. main.txt

If you build it like this:

g++ -O3 main.cpp

The output is not sorted, next timestamp should be 6000.

Next timestamp: 10000
Time: 6000, TaskType: 0
Time: 10000, TaskType: 1

Next timestamp should be 6000.

If you compile with O2 using g++, or you compile using clang++ however, the issue is fixed:

clang++ -O3 main.cpp
Next timestamp: 6000
Time: 6000, TaskType: 0
Time: 10000, TaskType: 1
wheremyfoodat commented 2 months ago

I was also affected by this problem in https://github.com/wheremyfoodat/Panda3DS

Lastique commented 2 months ago

This works as expected for me with Boost 1.84 but not 1.85. gcc 11.4, -O2, Kubuntu 22.04.

Lastique commented 2 months ago

Ah, sorry, I missed that you were using -O3. With it, it also fails with Boost 1.84.

igaztanaga commented 2 months ago

Please check the following commit, it should fix the issue:

https://github.com/boostorg/container/commit/20ad12f20e661978e90dc7f36d8ab8ac05e5a5a9

Lastique commented 2 months ago

With that commit applied to 1.85, this test produces the expected result for me:

Next timestamp: 6000
Time: 6000, TaskType: 0
Time: 10000, TaskType: 1

gcc 11.4, -O3, Kubuntu 22.04.

igaztanaga commented 1 month ago

Closing this as fixed after the commit. Thanks for the report.