HDF-4.2.14 compilation error with GCC-10


Hi all.

HDF(4)-4.2.14 is not compiling with latest GNU compiler release 10.0.1 on Fedora Linux (devel branch):

/bin/sh ../../libtool  --tag=F77   --mode=compile gfortran  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules  -c -o mfgrff.lo ../../../hdf/src/mfgrff.f
libtool: compile:  gfortran -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules -c ../../../hdf/src/mfgrff.f -o mfgrff.o
f951: Warning: '-Werror=' argument '-Werror=format-security' is not valid for Fortran
  132 |       mgsnatt = mgisattr(riid, name, nt, count, data, len(name))
      |                                                2
  155 |       mgsattr = mgisattr(riid, name, nt, count, data, len(name))
      |                                                1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(0)/INTEGER(4)).
make[3]: *** [Makefile:732: mfgrff.lo] Error 1

According to the GCC-10 release note, this type of error can be temporarily corrected by the flag -fallow-argument-mismatch as workaround.

Please, take a look before next HDF4 release.



Just hit this myself in trying out the newly stable and released GCC 10.1. If I pass in -fallow-argument-mismatch I do get a good compile.

Thanks @sagitter1 for posting this!


For anyone who gets here, this is still an issue in HDF4 4.2.15.


Thank you for reporting this. I added the issue, https://jira.hdfgroup.org/browse/HDFFR-1605, for the coming release of HDF4.


A clean fix is to change the called function on line 155 from mgisattr to mgiscatt. It is lucky that the correctly typed function had already been added.

However, make -k exposes 165 other argument mismatch errors with gfortran 12. This reflects an old fortran coding style for generic argument passing, where we used to care only about passing the start address of data objects of arbitrary type or shape.

For many of these cases, I think there would be a fair amount of work to split old-style generic procedures into type- and rank-specific ones. Is it worth the effort for this older HDF4 package, or is -fallow-argument-mismatch good enough for the future?


I see your point. I’ll bring it up to my group.
The answer is it’s not worth the effort and we’ll go with the flag: https://github.com/HDFGroup/hdf4/pull/10.