[flang-commits] [clang] [flang] [flang] Reject oversized -ffixed-line-length values (PR #229972)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Oct 8 15:56:01 PDT 2026
================
@@ -16,6 +17,7 @@
! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH
! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=4294967296 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=OVERFLOWLENGTH
----------------
eugeneepshteyn wrote:
(This comment was generated with the help of AI)
4294967296 is 2^32, so this test would still pass with a bound of `columns > UINT32_MAX`, which leaves 2147483648 through 4294967295 silently wrapping. Nothing checks that 2147483647 stays accepted either, so `columns >= INT_MAX` would also pass. Please pin both sides of the boundary:
```fortran
! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=2147483648 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=BOUNDARY
! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=2147483647 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
! BOUNDARY: invalid value '2147483648' in 'ffixed-line-length=', value must be '2147483647' or smaller
```
The 2147483648 line needs its own prefix because `OVERFLOWLENGTH` spells out `4294967296`. Without this PR, `-ffixed-line-length=2147483648` exits 0 with empty preprocessed output, so the new line fails there. `2147483647` matches `UNLIMITEDLENGTH` with and without the PR.
https://github.com/llvm/llvm-project/pull/229972
More information about the flang-commits
mailing list