stackoverflown icon indicating copy to clipboard operation
stackoverflown copied to clipboard

Incorrect comparison function - violates strict weak ordering

Open ineedanaccounttosearch opened this issue 2 months ago • 0 comments

https://github.com/KubaO/stackoverflown/blob/b3d59cfa491140759991f8a50392c785c9c50127/questions/qmap-qcolor-32512125/main.cpp#L4-L8

This comparison function violates the requirement for Strict Weak Ordering and will cause undefined behaviour/corruption inside the map.

Consider colours A(255, 0, 0) and B(0, 255, 0). Both A < B and B < A will return true.

ineedanaccounttosearch avatar Oct 21 '25 00:10 ineedanaccounttosearch