cplusplus / cplusplus/draft

[basic.def.odr] How is a default argument considered as a definition?

Open
#5,458 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[basic.def.odr] p1 says

Each of the following is termed a definable item:

  • [...]
  • a default argument for a parameter (for a function in a given scope) ([dcl.fct.default]), or

Then [basic.def.odr] p14 says

For any definable item D with definitions in multiple translation units,

  • [...]
  • if the definitions in different translation units do not satisfy the following requirements,

This obviously implies that a default argument is considered as a definition(also a declaration). But [basic.def] says

Each entity declared by a declaration is also defined by that declaration unless:

  • [...]

First, the italic declaration cross-references to subclause [dcl.pre], which didn't give a grammar meaning that is a declaration for the default argument, let alone how could it be a definition?

We lack a clarification for the default arguments that appear in non-template functions, which may have the similar manner as [temp.decls.general] p3 did

For purposes of name lookup and instantiation, default arguments, type-constraints, requires-clauses ([temp.pre]), and noexcept-specifiers of function templates and of member functions of class templates are considered definitions;

Might it be?

The default arguments of a function that is not templated are considered definitions.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read [basic.def.odr], [basic.def], and [temp.decls.general] together, focusing on how default arguments are classified for non-template functions. Determine whether the existing wording sufficiently defines their status and identify the smallest clarification needed. Done means the standard's definition and declaration terminology is unambiguous and consistent across these clauses.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.