Skip to content

[6.28] Backport of fix for argument-passing conventions in hbook#22575

Open
hageboeck wants to merge 5 commits into
root-project:v6-28-00-patchesfrom
hageboeck:hbook_6.28
Open

[6.28] Backport of fix for argument-passing conventions in hbook#22575
hageboeck wants to merge 5 commits into
root-project:v6-28-00-patchesfrom
hageboeck:hbook_6.28

Conversation

@hageboeck

Copy link
Copy Markdown
Member

guitargeek and others added 5 commits June 11, 2026 10:57
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`.

Note that 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. However, the type of these was changed with GCC 8 to size_t, so
we have to also account for that as recommended in [1]. 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

(cherry picked from commit aafddfb)
(cherry picked from commit f10c0ac)
Follow-up of root-project@aafddfb

(cherry picked from commit 34af31c)
(cherry picked from commit bcdd4fb)
When variable-length strings are passed into functions compiled by
gfortran, the lengths of the strings have to be passed at the end of the
argument list as size_t. When using gcc <= 7 or clang (where the
__GNUC__ macro might return unpredictable values), we were putting int on
the C side, which got interpreted as size_t on the fortran side.

(cherry picked from commit 3a9316e)
(cherry picked from commit 575fa7d)
Follow-up of root-project#20535

(cherry picked from commit 4ac2999)
(cherry picked from commit 3c3717f)
When variable-length strings are passed into functions compiled by
gfortran, the lengths of the strings have to be passed at the end of the
argument list as size_t. When using gcc <= 7 or clang (where the
__GNUC__ macro might return unpredictable values), we were putting int on
the C side, which got interpreted as size_t on the fortran side.

(cherry picked from commit 19fdba0)
(cherry picked from commit ed8a5dd)
@hageboeck hageboeck requested a review from dpiparo June 11, 2026 08:58
@hageboeck hageboeck self-assigned this Jun 11, 2026
@hageboeck hageboeck requested review from lmoneta and pcanal as code owners June 11, 2026 08:58
@github-actions

Copy link
Copy Markdown

Test Results

     5 files       5 suites   15h 31m 1s ⏱️
 2 431 tests  2 431 ✅ 0 💤 0 ❌
12 000 runs  12 000 ✅ 0 💤 0 ❌

Results for commit 1a059e1.

@dpiparo dpiparo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please merge asap! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants