Repository: Unidata/netcdf-c (c)

Issue:
can we now remove non-relaxed coord bounds?
See #1010 for the long discussion.

To summarize, coordinate bounds checking for netCDF-4 was originally slightly broken with parallel I/O. This was fixed (and the fix called "relaxed coord bounds"). Unfortunately, instead of just making the fix, an option was included to continue to build the old, incorrect code.

Using non-relaxed coord bounds is wrong and dangerous. This is reflected in the --enable documentation:
```
dnl Always build with relaxed coord bound checking, to prevent API
dnl incompatibilities between different installs of netCDF.
AC_ARG_ENABLE([zero-length-coord-bound],
   [AS_HELP_STRING([--disable-zero-length-coord-bound],
                   [Disable relaxed boundary error check. Deprecated. Using this can cause API incompatibilities. This option will be removed in the next release of netCDF.])])
test "x$enable_zero_length_coord_bound" = xno || enable_zero_length_coord_bound=yes
...
AC_SUBST(RELAX_COORD_BOUND,[$enable_zero_length_coord_bound])
```

Last time I brought this up, there was a lot going on, and I don't believe that this issue was properly resolved, but we all just moved on.

Now I would like to finally resolve this by removing the option to build without relaxed coord bounds. I'm sure no one is doing it, and, if they are, they should certainly not be. There is no benefit to continuing to support the old buggy behavior. We don't want users to write code that depends on non-relaxed coord bounds, under any circumstances.

@WardF, can I submit a PR with this resolved? 

Pull request description:
Make RELAX_COORD_BOUNDS mandatory for all builds
Fixes #1519

Patch:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b63da859f..7161e074d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1078,21 +1078,8 @@ IF(ENABLE_ERANGE_FILL) # enable or auto
 ENDIF(ENABLE_ERANGE_FILL)
 # Now ENABLE_ERANGE_FILL is either AUTO, ON, or OFF
 
-# Options to use a more relaxed coordinate argument boundary check
-SET(ENABLE_ZERO_LENGTH_COORD_BOUND AUTO CACHE STRING "AUTO")
-OPTION(ENABLE_ZERO_LENGTH_COORD_BOUND "Enable a more relaxed boundary error check NC_EINVALCOORDS to allow coordinate start argument equal to dimension size when argument count is zero." OFF)
-IF(ENABLE_ZERO_LENGTH_COORD_BOUND) # enable or auto
-   STRING(TOUPPER ${ENABLE_ZERO_LENGTH_COORD_BOUND} ENABLE_ZERO_LENGTH_COORD_BOUND)
-   IF(ENABLE_ZERO_LENGTH_COORD_BOUND AND NOT ENABLE_ZERO_LENGTH_COORD_BOUND STREQUAL "AUTO")
-      # explicitly enabled
-      SET(ENABLE_ZERO_LENGTH_COORD_BOUND ON)
-   ELSE()
-      IF(NOT ENABLE_ZERO_LENGTH_COORD_BOUND STREQUAL "AUTO")
-         SET(ENABLE_ZERO_LENGTH_COORD_BOUND OFF)
-      ENDIF()
-   ENDIF()
-ENDIF(ENABLE_ZERO_LENGTH_COORD_BOUND)
-# Now ENABLE_ZERO_LENGTH_COORD_BOUND is either AUTO, ON, or OFF
+# More relaxed coordinate check is now mandatory for all builds.
+SET(ENABLE_ZERO_LENGTH_COORD_BOUND ON)
 
 # check and conform with PnetCDF settings on ERANGE_FILL and RELAX_COORD_BOUND
 IF(STATUS_PNETCDF)
@@ -1123,17 +1110,9 @@ IF(STATUS_PNETCDF)
   ELSE()
      SET(relax_coord_bound_pnetcdf "OFF")
   ENDIF()
-  IF(ENABLE_ZERO_LENGTH_COORD_BOUND STREQUAL "AUTO") # not set on command line
-     SET(ENABLE_ZERO_LENGTH_COORD_BOUND "${relax_coord_bound_pnetcdf}")
-  ELSE()
-     # user explicitly set this option on command line
-     IF(NOT ENABLE_ZERO_LENGTH_COORD_BOUND STREQUAL "${relax_coord_bound_pnetcdf}")
-        IF(ENABLE_ZERO_LENGTH_COORD_BOUND)
-           MESSAGE(FATAL_ERROR "Enabling relax-coord-bound conflicts with PnetCDF setting")
-        ELSE()
-           MESSAGE(FATAL_ERROR "Disabling relax-coord-bound conflicts with PnetCDF setting")
-        ENDIF()
-     ENDIF()
+  # pnetcdf must have relaxed coord bounds to build with netCDF-4
+  IF(NOT ENABLE_ZERO_LENGTH_COORD_BOUND STREQUAL "${relax_coord_bound_pnetcdf}")
+     MESSAGE(FATAL_ERROR "Pnetcdf must be built with relax-coord-bound enabled")
   ENDIF()
 ENDIF()
 
diff --git a/configure.ac b/configure.ac
index 6fbf6b36e..584b32efd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1193,13 +1193,6 @@ AC_ARG_ENABLE([erange_fill],
    [enable_erange_fill=${enableval}], [enable_erange_fill=auto]
 )
 
-dnl Always build with relaxed coord bound checking, to prevent API
-dnl incompatibilities between different installs of netCDF.
-AC_ARG_ENABLE([zero-length-coord-bound],
-   [AS_HELP_STRING([--disable-zero-length-coord-bound],
-                   [Disable relaxed boundary error check. Deprecated. Using this can cause API incompatibilities. This option will be removed in the next release of netCDF.])])
-test "x$enable_zero_length_coord_bound" = xno || enable_zero_length_coord_bound=yes
-
 # check PnetCDF's settings on enable_erange_fill and relax_coord_bound
 if test "x$enable_pnetcdf" = xyes; then
    UD_CHECK_HEADER_PATH([pnetcdf.h])
@@ -1238,10 +1231,6 @@ else
    fi
 fi
 
-if test "x$enable_zero_length_coord_bound" = xyes; then
-   AC_DEFINE([RELAX_COORD_BOUND], [1], [if true, NC_EINVALCOORDS check is more relaxed])
-fi
-
 if test "x$enable_erange_fill" = xyes ; then
    if test "x$M4FLAGS" = x ; then
       M4FLAGS="-DERANGE_FILL"
@@ -1424,7 +1413,6 @@ AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
 AC_SUBST(HAS_DISKLESS,[yes])
 AC_SUBST(HAS_MMAP,[$enable_mmap])
 AC_SUBST(HAS_JNA,[$enable_jna])
-AC_SUBST(RELAX_COORD_BOUND,[$enable_zero_length_coord_bound])
 AC_SUBST(HAS_ERANGE_FILL,[$enable_erange_fill])
 AC_SUBST(HAS_BYTERANGE,[$enable_byterange])
 
@@ -1494,7 +1482,6 @@ AX_SET_META([NC_HAS_PARALLEL],[$enable_parallel],[yes])
 AX_SET_META([NC_HAS_PARALLEL4],[$enable_parallel4],[yes])
 AX_SET_META([NC_HAS_CDF5],[$enable_cdf5],[yes])
 AX_SET_META([NC_HAS_ERANGE_FILL], [$enable_erange_fill],[yes])
-AX_SET_META([NC_RELAX_COORD_BOUND], [$enable_zero_length_coord_bound],[yes])
 AX_SET_META([NC_HAS_BYTERANGE],[$enable_byterange],[yes])
 AC_SUBST([NC_DISPATCH_VERSION], [1])
 #####
diff --git a/include/netcdf_meta.h.in b/include/netcdf_meta.h.in
index 50a5d21b9..de44e7286 100644
--- a/include/netcdf_meta.h.in
+++ b/include/netcdf_meta.h.in
@@ -56,7 +56,7 @@
 
 #define NC_HAS_CDF5      @NC_HAS_CDF5@  /*!< CDF5 support. */
 #define NC_HAS_ERANGE_FILL @NC_HAS_ERANGE_FILL@ /*!< ERANGE_FILL Support */
-#define NC_RELAX_COORD_BOUND @NC_RELAX_COORD_BOUND@ /*!< RELAX_COORD_BOUND */
+#define NC_RELAX_COORD_BOUND 1 /*!< RELAX_COORD_BOUND */
 #define NC_DISPATCH_VERSION @NC_DISPATCH_VERSION@ /*!< Dispatch table version */
 
 #endif
diff --git a/libdispatch/dvarget.c b/libdispatch/dvarget.c
index 5b000e041..4eb41aa38 100644
--- a/libdispatch/dvarget.c
+++ b/libdispatch/dvarget.c
@@ -226,11 +226,8 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
         /* illegal value checks */
 	dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
         /* mystart is unsigned, never < 0 */
-#ifdef RELAX_COORD_BOUND
 	if (mystart[i] > dimlen) return NC_EINVALCOORDS;
-#else
-	if (mystart[i] >= dimlen) return NC_EINVALCOORDS;
-#endif
+
 	if(edges == NULL) {
 	   if(i == 0 && isrecvar)
   	      myedges[i] = numrecs - start[i];
@@ -238,9 +235,9 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
 	      myedges[i] = varshape[i] - mystart[i];
 	} else
 	    myedges[i] = edges[i];
-#ifdef RELAX_COORD_BOUND
+
 	if (mystart[i] == dimlen && myedges[i] > 0) return NC_EINVALCOORDS;
-#endif
+
         /* myedges is unsigned, never < 0 */
 	if(mystart[i] + myedges[i] > dimlen)
 	  return NC_EEDGE;
@@ -416,11 +413,7 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
 	    ? start[idim]
 	    : 0;
 
-#ifdef RELAX_COORD_BOUND
 	 if (mystart[idim] > dimlen)
-#else
-	 if (mystart[idim] >= dimlen)
-#endif
 	 {
 	    status = NC_EINVALCOORDS;
 	    goto done;
@@ -441,13 +434,11 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
 	    myedges[idim] = varshape[idim] - mystart[idim];
 #endif
 
-#ifdef RELAX_COORD_BOUND
 	 if (mystart[idim] == dimlen && myedges[idim] > 0)
 	 {
 	    status = NC_EINVALCOORDS;
 	    goto done;
 	 }
-#endif
 
 	 if (mystart[idim] + myedges[idim] > dimlen)
 	 {
diff --git a/libdispatch/dvarput.c b/libdispatch/dvarput.c
index 7f460b6f9..652e9a11c 100644
--- a/libdispatch/dvarput.c
+++ b/libdispatch/dvarput.c
@@ -221,11 +221,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
 #endif
         else {
 	  /* mystart is unsigned, will never be < 0 */
-#ifdef RELAX_COORD_BOUND
 	  if (mystart[i] > dimlen) return NC_EINVALCOORDS;
-#else
-          if (mystart[i] >= dimlen) return NC_EINVALCOORDS;
-#endif
        }
 	if(edges == NULL) {
 #if 0
@@ -239,12 +235,12 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
 	      myedges[i] = varshape[i] - mystart[i];
 	} else
 	    myedges[i] = edges[i];
-#ifdef RELAX_COORD_BOUND
+
 	if(!is_recdim[i]) {
 	  if (mystart[i] == dimlen && myedges[i] > 0)
               return NC_EINVALCOORDS;
         }
-#endif
+
 	if(!is_recdim[i]) {
           /* myediges is unsigned, will never be < 0 */
 	  if(mystart[i] + myedges[i] > dimlen)
@@ -434,12 +430,8 @@ NCDEFAULT_put_varm(
 
       for (idim = isrecvar; idim <= maxidim; ++idim)
       {
-#ifdef RELAX_COORD_BOUND
 	 if (mystart[idim] > varshape[idim] ||
 	    (mystart[idim] == varshape[idim] && myedges[idim] > 0))
-#else
-         if (mystart[idim] >= varshape[idim])
-#endif
 	 {
 	    status = NC_EINVALCOORDS;
 	    goto done;
diff --git a/libhdf5/hdf5var.c b/libhdf5/hdf5var.c
index 9df9d5079..78f0cad89 100644
--- a/libhdf5/hdf5var.c
+++ b/libhdf5/hdf5var.c
@@ -1586,19 +1586,12 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
             endindex = start[d2]; /* fixup for zero read count */
         if (!dim->unlimited)
         {
-#ifdef RELAX_COORD_BOUND
             /* Allow start to equal dim size if count is zero. */
             if (start[d2] > (hssize_t)fdims[d2] ||
                 (start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
                 BAIL_QUIET(NC_EINVALCOORDS);
             if (!zero_count && endindex >= fdims[d2])
                 BAIL_QUIET(NC_EEDGE);
-#else
-            if (start[d2] >= (hssize_t)fdims[d2])
-                BAIL_QUIET(NC_EINVALCOORDS);
-            if (endindex >= fdims[d2])
-                BAIL_QUIET(NC_EEDGE);
-#endif
         }
     }
 
@@ -1920,15 +1913,10 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
                 BAIL(retval);
 
             /* Check for out of bound requests. */
-#ifdef RELAX_COORD_BOUND
             /* Allow start to equal dim size if count is zero. */
             if (start[d2] > (hssize_t)ulen ||
                 (start[d2] == (hssize_t)ulen && count[d2] > 0))
                 BAIL_QUIET(NC_EINVALCOORDS);
-#else
-            if (start[d2] >= (hssize_t)ulen && ulen > 0)
-                BAIL_QUIET(NC_EINVALCOORDS);
-#endif
             if (count[d2] && endindex >= ulen)
                 BAIL_QUIET(NC_EEDGE);
 
@@ -1950,15 +1938,10 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
         else /* Dim is not unlimited. */
         {
             /* Check for out of bound requests. */
-#ifdef RELAX_COORD_BOUND
             /* Allow start to equal dim size if count is zero. */
             if (start[d2] > (hssize_t)fdims[d2] ||
                 (start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
                 BAIL_QUIET(NC_EINVALCOORDS);
-#else
-            if (start[d2] >= (hssize_t)fdims[d2])
-                BAIL_QUIET(NC_EINVALCOORDS);
-#endif
             if (count[d2] && endindex >= fdims[d2])
                 BAIL_QUIET(NC_EEDGE);
 
diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in
index fbe5853b2..50070720f 100644
--- a/libnetcdf.settings.in
+++ b/libnetcdf.settings.in
@@ -39,4 +39,4 @@ MMap Support:		@HAS_MMAP@
 JNA Support:		@HAS_JNA@
 CDF5 Support:		@HAS_CDF5@
 ERANGE Fill Support:	@HAS_ERANGE_FILL@
-Relaxed Boundary Check:	@RELAX_COORD_BOUND@
+Relaxed Boundary Check:	yes
diff --git a/libsrc/putget.m4 b/libsrc/putget.m4
index ebd0fc04a..dcbb91981 100644
--- a/libsrc/putget.m4
+++ b/libsrc/putget.m4
@@ -498,11 +498,7 @@ NCcoordck(NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
 	{
 		if(*coord > X_UINT_MAX) /* rkr: bug fix from previous X_INT_MAX */
 			return NC_EINVALCOORDS; /* sanity check */
-#ifdef RELAX_COORD_BOUND
 		if(NC_readonly(ncp) && *coord > NC_get_numrecs(ncp))
-#else
-		if(NC_readonly(ncp) && *coord >= NC_get_numrecs(ncp))
-#endif
 		{
 			if(!NC_doNsync(ncp))
 				return NC_EINVALCOORDS;
@@ -512,11 +508,7 @@ NCcoordck(NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
 				const int status = read_numrecs(ncp);
 				if(status != NC_NOERR)
 					return status;
-#ifdef RELAX_COORD_BOUND
 				if(*coord > NC_get_numrecs(ncp))
-#else
-				if(*coord >= NC_get_numrecs(ncp))
-#endif
 					return NC_EINVALCOORDS;
 			}
 		}
@@ -543,11 +535,7 @@ fprintf(stderr,"	NCcoordck: ip %p, *ip %ld, up %p, *up %lu\n",
 #endif /* CDEBUG */
 
 		/* cast needed for braindead systems with signed size_t */
-#ifdef RELAX_COORD_BOUND
 		if((unsigned long) *ip > (unsigned long) *up )
-#else
-		if((unsigned long) *ip >= (unsigned long) *up )
-#endif
 			return NC_EINVALCOORDS;
 	}
 
@@ -571,11 +559,9 @@ NCedgeck(const NC3_INFO* ncp, const NC_var *varp,
 
 	if(IS_RECVAR(varp))
 	{
-#ifdef RELAX_COORD_BOUND
 		if (NC_readonly(ncp) &&
                     (start[0] == NC_get_numrecs(ncp) && edges[0] > 0))
 			return(NC_EINVALCOORDS);
-#endif
 		start++;
 		edges++;
 		shp++;
@@ -583,10 +569,8 @@ NCedgeck(const NC3_INFO* ncp, const NC_var *varp,
 
 	for(; start < end; start++, edges++, shp++)
 	{
-#ifdef RELAX_COORD_BOUND
 		if ((unsigned long) *start == *shp && *edges > 0)
 			return(NC_EINVALCOORDS);
-#endif
 		/* cast needed for braindead systems with signed size_t */
 		if((unsigned long) *edges > *shp ||
 			(unsigned long) *start + (unsigned long) *edges > *shp)


Test patch:
diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am
index ceaf9ecda..c8fa6f5db 100644
--- a/nc_test/Makefile.am
+++ b/nc_test/Makefile.am
@@ -127,7 +127,7 @@ endif
 
 # Only clean these on maintainer-clean, because they require m4 to
 # regenerate.
-#MAINTAINERCLEANFILES = test_get.c test_put.c
+MAINTAINERCLEANFILES = test_get.c test_put.c
 
 # This rule tells make how to turn our .m4 files into .c files.
 .m4.c:
diff --git a/nc_test/test_get.m4 b/nc_test/test_get.m4
index 1e81e5667..19d9e043c 100644
--- a/nc_test/test_get.m4
+++ b/nc_test/test_get.m4
@@ -487,13 +487,8 @@ ifelse(`$1',`uchar',`ifdef(`PNETCDF',,``#'endif')')
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
             err = GetVara($1)(ncid, i, start, edge, value);
             IF (err != NC_EINVALCOORDS)
@@ -756,13 +751,8 @@ ifdef(`PNETCDF',`dnl
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             start[j] = var_shape[i][j]+1;  /* should cause NC_EINVALCOORDS */
             err = GetVars($1)(ncid, i, start, edge, stride, value);
             IF (err != NC_EINVALCOORDS)
@@ -1054,13 +1044,8 @@ ifdef(`PNETCDF',`dnl
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             start[j] = var_shape[i][j]+1;  /* should cause NC_EINVALCOORDS */
             err = GetVarm($1)(ncid, i, start, edge, stride, imap, value);
             IF (err != NC_EINVALCOORDS)
diff --git a/nc_test/test_put.m4 b/nc_test/test_put.m4
index 0d6705ed0..5f7cb0171 100644
--- a/nc_test/test_put.m4
+++ b/nc_test/test_put.m4
@@ -778,13 +778,8 @@ ifdef(`PNETCDF',`dnl
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVara($1)(ncid, i, start, edge, value);
@@ -1007,13 +1002,8 @@ ifdef(`PNETCDF',`dnl
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVars($1)(ncid, i, start, edge, stride, value);
@@ -1259,13 +1249,8 @@ ifdef(`PNETCDF',`dnl
                 start[j] = 0;
                 continue;
             }
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVarm($1)(ncid, i, start, edge, stride, imap, value);
diff --git a/nc_test/test_read.m4 b/nc_test/test_read.m4
index 4434d6d31..41bc5b55e 100644
--- a/nc_test/test_read.m4
+++ b/nc_test/test_read.m4
@@ -1207,13 +1207,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = GetVara(ncid, i, start, edge, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1;  /* out of boundary check */
             err = GetVara(ncid, i, start, edge, buf, 1, datatype);
@@ -1399,13 +1394,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = GetVars(ncid, i, start, edge, stride, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1;  /* out of boundary check */
             err = GetVars(ncid, i, start, edge, stride, buf, 1, datatype);
@@ -1628,13 +1618,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = GetVarm(ncid, i, start, edge, stride, imap, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1;  /* out of boundary check */
             err = GetVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
diff --git a/nc_test/test_write.m4 b/nc_test/test_write.m4
index 4650e3706..6d011971b 100644
--- a/nc_test/test_write.m4
+++ b/nc_test/test_write.m4
@@ -1043,13 +1043,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = PutVara(ncid, i, start, edge, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVara(ncid, i, start, edge, buf, 1, datatype);
@@ -1236,13 +1231,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == 0) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = PutVars(ncid, i, start, edge, stride, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
@@ -1459,13 +1449,8 @@ ifdef(`PNETCDF',`dnl
             if (var_dimid[i][j] == 0) continue; /* skip record dim */
             start[j] = var_shape[i][j];
             err = PutVarm(ncid, i, start, edge, stride, imap, buf, 0, datatype);
-#ifdef RELAX_COORD_BOUND
             IF (err != NC_NOERR) /* allowed when edge[j]==0 */
                 EXPECT_ERR(NC_NOERR, err)
-#else
-            IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
-                EXPECT_ERR(NC_EINVALCOORDS, err)
-#endif
             ELSE_NOK
             start[j] = var_shape[i][j]+1; /* out of boundary check */
             err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);