From d9a8ea423880c27c5a0ab2593f8df790e030317f Mon Sep 17 00:00:00 2001 From: Daniel Dresser Date: Fri, 16 Jan 2026 14:23:49 -0800 Subject: [PATCH] IECore::MurmurHash::append : Fix bug with Imath::Box in GCC --- include/IECore/MurmurHash.inl | 3 ++- test/IECore/MurmurHashTest.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/IECore/MurmurHash.inl b/include/IECore/MurmurHash.inl index 46d015efaa..1c40a4ed01 100644 --- a/include/IECore/MurmurHash.inl +++ b/include/IECore/MurmurHash.inl @@ -347,7 +347,8 @@ inline void murmurHashAppend( MurmurHash &h, const Imath::Matrix44 &data ) template inline void murmurHashAppend( MurmurHash &h, const Imath::Box &data ) { - h.append( &data.min, 2 ); + h.append( data.min ); + h.append( data.max ); } template diff --git a/test/IECore/MurmurHashTest.cpp b/test/IECore/MurmurHashTest.cpp index 98b81dc84b..7a15c18b46 100644 --- a/test/IECore/MurmurHashTest.cpp +++ b/test/IECore/MurmurHashTest.cpp @@ -69,6 +69,35 @@ struct MurmurHashTest // many elements in it - currently, I'm seeing a max occupancy of 8. BOOST_CHECK( maxBucketOccupancy < 16 ); } + + void testAllElementsOfImathBoxes() + { + Imath::Box3i ref( Imath::V3i( 123, 456, 789 ), Imath::V3i( 10123, 10456, 10789 ) ); + std::unordered_set< IECore::MurmurHash > set; + + for( int i = 0; i < 6; i++ ) + { + for( int j = 0; j < 32; j++ ) + { + int bitToFlip = 1 << j; + Imath::Box3i q = ref; + if( i >= 3 ) + { + q.max[i - 3] = bitToFlip ^ q.max[i - 3]; + } + else + { + q.min[i] = bitToFlip ^ q.min[i]; + } + + IECore::MurmurHash h; + h.append( q ); + set.insert( h ); + } + } + + BOOST_CHECK( set.size() == ( 6 * 32 ) ); + } }; @@ -80,6 +109,7 @@ struct MurmurHashTestSuite : public boost::unit_test::test_suite boost::shared_ptr instance( new MurmurHashTest() ); add( BOOST_CLASS_TEST_CASE( &MurmurHashTest::testUnorderedSet, instance ) ); + add( BOOST_CLASS_TEST_CASE( &MurmurHashTest::testAllElementsOfImathBoxes, instance ) ); } };