Landing: 4cb7258da9bd

Project / Subsystem

gcc / libstdc++

Date

2026-08-16

Author

Anlai Lu

Commit

4cb7258da9bd637ccce023693ae6a167d179784d

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
libstdc++
patch_id
—
commit_hash
4cb7258da9bd637ccce023693ae6a167d179784d
source_type
github
headline
Fix SIGSEGV in std::print with a setvbuf'd FILE
tldr
std::print now correctly handles FILE streams set with setvbuf, preventing SIGSEGV.
author
Anlai Lu
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • libstdc++
  • • formatting
  • • bugfix
discussion_id_link
—
bugzilla_pr
—
date
2026-08-16T00:00:00.000Z

This commit fixes a regression in std::print that caused a segmentation fault when formatting output to a FILE* stream that had been configured with setvbuf. The issue arose because the new P3107R5 implementation’s file sink logic did not properly handle the stream state previously managed by fwrite. The fix ensures that __overflow is called correctly during the initialization of the file sink’s write buffer when the write pointer is null, restoring proper stream handling.