cplusplus / cplusplus/draft

[dcl.init.general] default-initialization vs extern declaration

Open
#4,799 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

struct A{
  A(){}
};
extern A a; // #1

For the declaration at #1, should we say since there is no initializer specified for the object, hence default-initialization is applied?

Specifically, Is there any normative rule in the standard that specifies which declaration the initialization will be applied to?
Except for a note [dcl.init.general.note-10], it seems it's unclear whether the initialization is performed(on a declaration).

Could we change [dcl.init.general] p20 to

A simple-declaration that is definition specifies the initialization of a variable, whether from an explicit initializer or by default-initialization, is called the initializing declaration of that variable.

The modification does not impact member-declarations or parameter declarations, and it can clarify the above example.

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

Start with [dcl.init.general] p20 and note-10, then trace the wording for simple-declarations, definitions, and initializing declarations in the C++ draft. Determine whether the standard clearly assigns default-initialization in the extern example and whether the proposed clarification is normatively appropriate; done means the issue has an agreed resolution and wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.