GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran: Fix namelist read for input with comments

The Fortran compiler now correctly parses namelist input containing comments.

The Fortran compiler now correctly handles comments within namelist input. Comments, indicated by a !, are skipped until the end of the line, and leading whitespace in subsequent input records is ignored. This fixes an issue where the compiler would fail to parse namelist input containing comments, improving Fortran language support.

In Details

This patch modifies libgfortran/io/list_read.c to handle comments in namelist read mode for logical, integer, character, complex, and real data types. The fix ensures that comments are skipped until the end of the line, and leading whitespace is eaten in subsequent input records. This resolves PR125095.

For Context

This commit fixes a bug in the Fortran compiler related to how it reads input data using the namelist feature. Namelist allows reading data into variables by name, rather than by position. The fix ensures that the compiler correctly ignores comments (lines starting with !) within the input data, allowing programs to use comments to explain the data without causing errors. This makes the compiler more robust and easier to use.

Filed Under: fortrannamelistbugfixparsing