diff --git a/src/fmpi_data.c b/src/fmpi_data.c
index 63b4744b377b10f7d6a8a6b04262c77dc0a47293..523ad4cfef720034502e2b92384198d45f8c6504 100644
--- a/src/fmpi_data.c
+++ b/src/fmpi_data.c
@@ -57,11 +57,11 @@ struct fmpi_data fmpi_data_out_##T( \
 FMPI_DEFINE_FUNCS_T(FMPI_DATA_FUNC_DEFINITION_T, FMPI_DATA_TYPES)
 
 #define FMPI_DATA_FUNC_DEFINITION_DT(D, T) \
+_Static_assert((D) > 0 && (D) <= FMPI_DIM_MAX, ""); \
 struct fmpi_data fmpi_data_##D##d_in_##T( \
     const struct fmpi_ctx * const ctx, T * const data, \
     const size_t x, const size_t y, const size_t z \
 ){ \
-    _Static_assert((D) <= FMPI_DIM_MAX, ""); \
     assert(ctx != NULL); \
     assert(data != NULL); \
     const size_t cnt = (x * y * z); \
@@ -83,7 +83,6 @@ struct fmpi_data fmpi_data_##D##d_out_##T( \
     const struct fmpi_ctx * const ctx, T * const data, \
     const size_t x, const size_t y, const size_t z \
 ){ \
-    _Static_assert((D) <= FMPI_DIM_MAX, ""); \
     assert(ctx != NULL); \
     assert(data != NULL); \
     const size_t cnt = (x * y * z); \