[basic.scope.pdecl]

# 6 Basics [[basic]](./#basic)

## 6.4 Scope [[basic.scope]](basic.scope#pdecl)

### 6.4.2 Point of declaration [basic.scope.pdecl]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1237)

The [*locus*](#def:locus "6.4.2 Point of declaration [basic.scope.pdecl]") of a declaration ([[basic.pre]](basic.pre "6.1 Preamble")) that is a declarator
is immediately after the complete declarator ([[dcl.decl]](dcl.decl "9.3 Declarators"))[.](#1.sentence-1)

[*Example [1](#example-1)*: unsigned char x = 12;{ unsigned char x = x; }

Here, the initialization of the second x has undefined behavior,
because the initializer accesses the second x outside its lifetime ([[basic.life]](basic.life "6.8.4 Lifetime"))[.](#1.sentence-2)

â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1251)

[*Note [1](#note-1)*:

A name from an outer scope remains visible up to
the locus of the declaration that hides it[.](#2.sentence-1)

[*Example [2](#example-2)*:

const int i = 2;{ int i[i]; } declares a block-scope array of two integers[.](#2.sentence-2)

â *end example*]

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1265)

The locus of a [*class-specifier*](class.pre#nt:class-specifier "11.1 Preamble [class.pre]") is immediately after
the [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") or [*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]") (if any)
in its [*class-head*](class.pre#nt:class-head "11.1 Preamble [class.pre]") ([[class.pre]](class.pre "11.1 Preamble"))[.](#3.sentence-1)

The locus of an [*enum-specifier*](dcl.enum#nt:enum-specifier "9.8.1 Enumeration declarations [dcl.enum]") is immediately after
its [*enum-head*](dcl.enum#nt:enum-head "9.8.1 Enumeration declarations [dcl.enum]");
the locus of an [*opaque-enum-declaration*](dcl.enum#nt:opaque-enum-declaration "9.8.1 Enumeration declarations [dcl.enum]") is immediately after it ([[dcl.enum]](dcl.enum "9.8.1 Enumeration declarations"))[.](#3.sentence-2)

The locus of an [*alias-declaration*](dcl.pre#nt:alias-declaration "9.1 Preamble [dcl.pre]") is immediately after it[.](#3.sentence-3)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1277)

The locus of a [*using-declarator*](namespace.udecl#nt:using-declarator "9.10 The using declaration [namespace.udecl]") that does not name a constructor
is immediately after the [*using-declarator*](namespace.udecl#nt:using-declarator "9.10 The using declaration [namespace.udecl]") ([[namespace.udecl]](namespace.udecl "9.10 The using declaration"))[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1282)

The locus of an [*enumerator-definition*](dcl.enum#nt:enumerator-definition "9.8.1 Enumeration declarations [dcl.enum]") is immediately after it[.](#5.sentence-1)

[*Example [3](#example-3)*: const int x = 12;{ enum { x = x }; }

Here, the enumerator x is initialized with the value of the
constant x, namely 12[.](#5.sentence-2)

â *end example*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1293)

[*Note [2](#note-2)*:

After the declaration of a class member,
the member name can be found in the scope of its class
even if the class is an incomplete class[.](#6.sentence-1)

[*Example [4](#example-4)*: struct X {enum E { z = 16 }; int b[X::z]; // OK}; â *end example*]

â *end note*]

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1309)

The locus of an [*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5 Elaborated type specifiers [dcl.type.elab]") that is a declaration ([[dcl.type.elab]](dcl.type.elab "9.2.9.5 Elaborated type specifiers")) is immediately after it[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1313)

The locus of an injected-class-name declaration ([[class.pre]](class.pre "11.1 Preamble"))
is immediately following the opening brace of the class definition[.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1317)

The locus of the implicit declaration of
a function-local predefined variable ([[dcl.fct.def.general]](dcl.fct.def.general "9.6.1 General"))
is immediately before
the [*function-body*](dcl.fct.def.general#nt:function-body "9.6.1 General [dcl.fct.def.general]") of its function's definition[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1323)

The locus of the declaration of a structured binding ([[dcl.struct.bind]](dcl.struct.bind "9.7 Structured binding declarations"))
is immediately after
the [*identifier-list*](cpp.pre#nt:identifier-list "15.1 Preamble [cpp.pre]") of the structured binding declaration[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1328)

The locus of a [*for-range-declaration*](stmt.pre#nt:for-range-declaration "8.1 Preamble [stmt.pre]") of a range-based for statement ([[stmt.ranged]](stmt.ranged "8.6.5 The range-based for statement"))
is immediately after the [*for-range-initializer*](stmt.pre#nt:for-range-initializer "8.1 Preamble [stmt.pre]")[.](#11.sentence-1)

The locus of a [*for-range-declaration*](stmt.pre#nt:for-range-declaration "8.1 Preamble [stmt.pre]") of an expansion statement ([[stmt.expand]](stmt.expand "8.7 Expansion statements"))
is immediately after the [*expansion-initializer*](stmt.expand#nt:expansion-initializer "8.7 Expansion statements [stmt.expand]")[.](#11.sentence-2)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1336)

The locus of a [*template-parameter*](temp.param#nt:template-parameter "13.2 Template parameters [temp.param]") is immediately after it[.](#12.sentence-1)

[*Example [5](#example-5)*: typedef unsigned char T;template<class T = T // lookup finds the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") , T // lookup finds the template parameter N = 0> struct A { }; â *end example*]

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1348)

The locus of a [*result-name-introducer*](dcl.contract.res#nt:result-name-introducer "9.4.2 Referring to the result object [dcl.contract.res]") ([[dcl.contract.res]](dcl.contract.res "9.4.2 Referring to the result object"))
is immediately after it[.](#13.sentence-1)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1352)

The locus of a [*concept-definition*](temp.concept#nt:concept-definition "13.7.9 Concept definitions [temp.concept]") is immediately after its [*concept-name*](temp.concept#nt:concept-name "13.7.9 Concept definitions [temp.concept]") ([[temp.concept]](temp.concept "13.7.9 Concept definitions"))[.](#14.sentence-1)

[*Note [3](#note-3)*:

The [*constraint-expression*](temp.constr.decl#nt:constraint-expression "13.5.3 Constrained declarations [temp.constr.decl]") cannot use
the [*concept-name*](temp.concept#nt:concept-name "13.7.9 Concept definitions [temp.concept]")[.](#14.sentence-2)

â *end note*]

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1360)

The locus of a [*namespace-definition*](namespace.def.general#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") with an [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") is immediately after the [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")[.](#15.sentence-1)

[*Note [4](#note-4)*:

An identifier is invented
for an [*unnamed-namespace-definition*](namespace.def.general#nt:unnamed-namespace-definition "9.9.2.1 General [namespace.def.general]") ([[namespace.unnamed]](namespace.unnamed "9.9.2.2 Unnamed namespaces"))[.](#15.sentence-2)

â *end note*]

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1369)

[*Note [5](#note-5)*:

Friend declarations can introduce functions or classes
that belong to the nearest enclosing namespace or block scope,
but they do not bind names anywhere ([[class.friend]](class.friend "11.8.4 Friends"))[.](#16.sentence-1)

Function declarations at block scope and
variable declarations with the extern specifier at block scope
declare entities
that belong to the nearest enclosing namespace,
but they do not bind names in it[.](#16.sentence-2)

â *end note*]

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1381)

[*Note [6](#note-6)*:

For point of instantiation of a template, see [[temp.point]](temp.point "13.8.4.1 Point of instantiation")[.](#17.sentence-1)

â *end note*]
