Summary
Clang flags two operator precedence ambiguities in dverb2.c where - is evaluated before <<, potentially diverging from the original FORTRAN intent.
Background
The CI pipeline introduced in PR #38 revealed two -Wshift-op-parentheses warnings from Clang in dverb2.c, both in the mirror/maze room navigation logic.
Line 493: curxt_1.xroom1 - rindex_1.mra << 1 is evaluated as (curxt_1.xroom1 - rindex_1.mra) << 1 because - has higher precedence than <<.
Line 557: findex_1.mloc - rindex_1.mra << 1 follows the same pattern.
If the original FORTRAN intended a multiply-by-two of the subtraction result, the current C code is correct.
If it intended to shift mra first and then subtract, this is a latent navigation bug in the mirror rooms.
Details
- Locate the original FORTRAN source for the
CXAPPL function (the cxappl_ static function in dverb2.c) to determine the intended arithmetic.
- In FORTRAN,
ISHFT is the shift operation — determine whether the original used ISHFT(X - Y, 1) or X - ISHFT(Y, 1).
- If the C precedence matches the FORTRAN semantics, add explicit parentheses to document the intent and silence the warning.
- If the behavior diverges, add parentheses to correct the grouping.
This can be fixed as part of v1.1.0, but will most likely be addressed in a future release to help get recent changes submitted downstream in the Fedora package.
Outcome
The mirror room navigation arithmetic is verified against the original FORTRAN source and parenthesized to remove the ambiguity and silence the Clang -Wshift-op-parentheses warnings.
Summary
Clang flags two operator precedence ambiguities in
dverb2.cwhere-is evaluated before<<, potentially diverging from the original FORTRAN intent.Background
The CI pipeline introduced in PR #38 revealed two
-Wshift-op-parentheseswarnings from Clang indverb2.c, both in the mirror/maze room navigation logic.Line 493:
curxt_1.xroom1 - rindex_1.mra << 1is evaluated as(curxt_1.xroom1 - rindex_1.mra) << 1because-has higher precedence than<<.Line 557:
findex_1.mloc - rindex_1.mra << 1follows the same pattern.If the original FORTRAN intended a multiply-by-two of the subtraction result, the current C code is correct.
If it intended to shift
mrafirst and then subtract, this is a latent navigation bug in the mirror rooms.Details
CXAPPLfunction (thecxappl_static function indverb2.c) to determine the intended arithmetic.ISHFTis the shift operation — determine whether the original usedISHFT(X - Y, 1)orX - ISHFT(Y, 1).This can be fixed as part of v1.1.0, but will most likely be addressed in a future release to help get recent changes submitted downstream in the Fedora package.
Outcome
The mirror room navigation arithmetic is verified against the original FORTRAN source and parenthesized to remove the ambiguity and silence the Clang
-Wshift-op-parentheseswarnings.