Skip to content

Commit 372e60d

Browse files
committed
Trade: make the MaterialData duplicate asserts more paranoid.
Libc++ is that you who's this shitty?
1 parent f51110f commit 372e60d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/Magnum/Trade/MaterialData.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,13 @@ MaterialData::MaterialData(const MaterialTypes types, Containers::Array<Material
233233
std::sort(_data + begin, _data + end, [](const MaterialAttributeData& a, const MaterialAttributeData& b) {
234234
/* Need to check here (instead of in the outer for loop) as we
235235
exit the loop right after the sort and thus duplicates that
236-
occur after the first non-sorted pair wouldn't get detected. */
237-
CORRADE_ASSERT(a.name() != b.name(),
236+
occur after the first non-sorted pair wouldn't get detected.
237+
238+
Additionally an *extra paranoid* check for shitty STL
239+
implementations that might call this comparator with both
240+
arguments the same (in which case the assert would fire,
241+
which is undesirable). */
242+
CORRADE_ASSERT(&a == &b || a.name() != b.name(),
238243
"Trade::MaterialData: duplicate attribute" << a.name(), false);
239244
return a.name() < b.name();
240245
});

0 commit comments

Comments
 (0)