container icon indicating copy to clipboard operation
container copied to clipboard

flat_multimap::emplace not sorting elements under GCC

Open OFFTKP opened this issue 1 year ago • 5 comments

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

OFFTKP avatar Mar 07 '24 21:03 OFFTKP

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

wheremyfoodat avatar Apr 13 '24 12:04 wheremyfoodat

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

Lastique avatar Apr 20 '24 11:04 Lastique

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

Lastique avatar Apr 20 '24 11:04 Lastique

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

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

igaztanaga avatar Apr 28 '24 21:04 igaztanaga

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.

Lastique avatar Apr 29 '24 12:04 Lastique

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

igaztanaga avatar May 23 '24 21:05 igaztanaga