Landing: 5d3472d4933b

Project / Subsystem

gcc / fortran

Date

2026-04-17

Author

Paul Thomas

Commit

5d3472d4933b11c26eebcd67c9227f8ada3451ed

Source

github

Impact

5/10

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
fortran
patch_id
commit_hash
5d3472d4933b11c26eebcd67c9227f8ada3451ed
source_type
github
headline
Fortran: Fix wrong result for SPREAD with ncopies < 0.
tldr
The `SPREAD` intrinsic in Fortran now correctly handles negative `ncopies` arguments, which produce a zero-sized array.
why_it_matters
The `SPREAD` intrinsic is used to replicate an array along a specified dimension, and correct handling of edge cases is important for numerical simulations.
author
Paul Thomas
impact_score
5
impact_rationale
Fixes a bug in a Fortran intrinsic function that could lead to incorrect results.
outcome
committed
performance_win
false
breaking_change
false
series_id
series_parts
[]
tags
  • fortran
  • intrinsic
  • array
  • bugfix
discussion_id_link
bugzilla_pr
date
2026-04-17T00:00:00.000Z

The SPREAD intrinsic in Fortran was producing incorrect results when the ncopies argument was negative. The fix modifies the spread.m4 macro to handle the scalar source case with ncopies < 0, which should result in a zero-sized array. The generated code for various data types has been regenerated, and a new test case has been added.