Skip to content

Commit 574826b

Browse files
committed
[h2root] Fix declaration and usage of hropen
According to the `gfortran` argument passing conventions, for any Fortran procedure, the compiler will automatically define a C prototype. This is what we use in `h2root`. However, for procedures like `HROPEN` that takes string arguments, the signature of the C prototype will have extra arguments for the string lengths, which we also have to include in our forward declaration and usage. Otherwise, we get undefined behavor, which causes the `h2root` test to fail on ARM64 with GCC 14. [1] https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html
1 parent b92c0fa commit 574826b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

main/src/h2root.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ extern "C" void type_of_call hlimit(const int&);
171171
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR,
172172
const int&,const int&,const int,const int,const int);
173173
#else
174-
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR,
175-
const int&,const int&);
174+
extern "C" void type_of_call hropen(int*,DEFCHAR,DEFCHAR,DEFCHAR,
175+
int*,int*,size_t,size_t,size_t);
176176
#endif
177177

178178
extern "C" void type_of_call hrin(const int&,const int&,const int&);
@@ -318,7 +318,8 @@ int main(int argc, char **argv)
318318
auto opt = PASSCHAR("px ");
319319
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),opt,record_size,ier,7,strlen(file_in),2);
320320
#else
321-
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("px"),record_size,ier);
321+
hropen(&lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("px"),&record_size,&ier,
322+
strlen("example"), strlen(file_in), strlen("px"));
322323
#endif
323324

324325
if (ier) printf (" Error on hropen was %d \n", ier);

0 commit comments

Comments
 (0)