diff --git a/python/mesa_pd/templates/data/ShapeStorage.templ.h b/python/mesa_pd/templates/data/ShapeStorage.templ.h
index 230f6a923ab392b90448961744e825a1b6905c8f..772628ea6ae98307622d83a2c373f6457316d287 100644
--- a/python/mesa_pd/templates/data/ShapeStorage.templ.h
+++ b/python/mesa_pd/templates/data/ShapeStorage.templ.h
@@ -58,8 +58,10 @@ struct ShapeStorage
    ReturnType doubleDispatch( ParticleStorage& ps, size_t idx, size_t idy, func& f );
 };
 //Make sure that no two different shapes have the same unique identifier!
-{%- for shape in particle.shapes[1:] %}
-static_assert( {{particle.shapes[0]}}::SHAPE_TYPE != {{shape}}::SHAPE_TYPE, "Shape types have to be different!" );
+{%- for shape1 in particle.shapes %}
+{%- for shape2 in particle.shapes[loop.index:] %}
+static_assert( {{shape1}}::SHAPE_TYPE != {{shape2}}::SHAPE_TYPE, "Shape types have to be different!" );
+{%- endfor %}
 {%- endfor %}
 
 template <typename ShapeT, typename... Args>
diff --git a/src/mesa_pd/data/ShapeStorage.h b/src/mesa_pd/data/ShapeStorage.h
index f7e158d0e40e9bc9c6f16e678b74001b7b27925c..a8baee5c713ddf991286a6e6ef6bc21055d4affb 100644
--- a/src/mesa_pd/data/ShapeStorage.h
+++ b/src/mesa_pd/data/ShapeStorage.h
@@ -64,6 +64,12 @@ static_assert( Sphere::SHAPE_TYPE != HalfSpace::SHAPE_TYPE, "Shape types have to
 static_assert( Sphere::SHAPE_TYPE != CylindricalBoundary::SHAPE_TYPE, "Shape types have to be different!" );
 static_assert( Sphere::SHAPE_TYPE != Box::SHAPE_TYPE, "Shape types have to be different!" );
 static_assert( Sphere::SHAPE_TYPE != Ellipsoid::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( HalfSpace::SHAPE_TYPE != CylindricalBoundary::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( HalfSpace::SHAPE_TYPE != Box::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( HalfSpace::SHAPE_TYPE != Ellipsoid::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( CylindricalBoundary::SHAPE_TYPE != Box::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( CylindricalBoundary::SHAPE_TYPE != Ellipsoid::SHAPE_TYPE, "Shape types have to be different!" );
+static_assert( Box::SHAPE_TYPE != Ellipsoid::SHAPE_TYPE, "Shape types have to be different!" );
 
 template <typename ShapeT, typename... Args>
 size_t ShapeStorage::create(Args&&... args)