On Wed, Jan 08, 2025 at 06:23:40PM +0100, Andre Vehreschild wrote: > gcc/fortran/ChangeLog: > > PR fortran/118337 > * module.cc (use_iso_fortran_env_module): Prevent additional run > over (un-)signed ints and assign kind directly. > --- > gcc/fortran/module.cc | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc > index de8df05781d..8dc10e1d349 100644 > --- a/gcc/fortran/module.cc > +++ b/gcc/fortran/module.cc > @@ -7113,8 +7113,8 @@ use_iso_fortran_env_module (void) > int i, j; > > intmod_sym symbol[] = { > -#define NAMED_INTCST(a,b,c,d) { a, b, 0, d }, > -#define NAMED_UINTCST(a,b,c,d) { a, b, 0, d }, > +#define NAMED_INTCST(a, b, c, d) {a, b, c, d}, > +#define NAMED_UINTCST(a, b, c, d) {a, b, c, d}, > #define NAMED_KINDARRAY(a,b,c,d) { a, b, 0, d }, > #define NAMED_DERIVED_TYPE(a,b,c,d) { a, b, 0, d }, > #define NAMED_FUNCTION(a,b,c,d) { a, b, c, d }, > @@ -7122,15 +7122,6 @@ use_iso_fortran_env_module (void) > #include "iso-fortran-env.def" > { ISOFORTRANENV_INVALID, NULL, -1234, 0 } }; > > - i = 0; > -#define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; > -#define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; > -#define NAMED_KINDARRAY(a,b,c,d) i++; > -#define NAMED_DERIVED_TYPE(a,b,c,d) i++; > -#define NAMED_FUNCTION(a,b,c,d) i++; > -#define NAMED_SUBROUTINE(a,b,c,d) i++; > -#include "iso-fortran-env.def" > -
I thought the reason was that NAMED_{,U}INTCST c is non-constant while everything else is constant and the source trying to help the C++ compiler to emit decent code for it. Though, I think g++ will end up doing pretty much the same thing, split the non-constant parts of the initializer into statements overwriting values in the variable and using 0 for that in the initializer before it is overwritten. Anyway, if you go with your patch, please use { a, b, c, d }, rather than {a, b, c, d}, for consistency with surrounding code. Jakub