Landing: 5fd9f0f77f2b

Project / Subsystem

gcc / c++

Date

2026-05-11

Author

Marek Polacek

Commit

5fd9f0f77f2bdb9a2843bb9b9b55ab6bd2cbd5c8

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
c++
patch_id
commit_hash
5fd9f0f77f2bdb9a2843bb9b9b55ab6bd2cbd5c8
source_type
github
headline
C++: Correctly parses default arguments referring to parameters.
tldr
Fixes a bug where default arguments could not refer to earlier parameters in the function declaration.
author
Marek Polacek
outcome
committed
performance_win
false
breaking_change
false
series_id
series_parts
[]
tags
  • c++
  • parser
  • default argument
  • bugfix
discussion_id_link
bugzilla_pr
date
2026-05-11T00:00:00.000Z

This commit fixes a bug where default arguments in C++ function declarations could not correctly refer to preceding parameters. The issue arose because the parser wasn’t properly associating the parameter’s scope before parsing the default argument. Now, code like void fn (int i = sizeof (i)) {} (where i in sizeof refers to the parameter) is correctly parsed.