[dcl.ptr]

# 9 Declarations [[dcl]](./#dcl)

## 9.3 Declarators [[dcl.decl]](dcl.decl#dcl.ptr)

### 9.3.4 Meaning of declarators [[dcl.meaning]](dcl.meaning#dcl.ptr)

#### 9.3.4.2 Pointers [dcl.ptr]

[1](#1)

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

In a declarationTD whereD has the form

* [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*cv-qualifier-seq*](dcl.decl.general#nt:cv-qualifier-seq "9.3.1 General [dcl.decl.general]")opt D1

and the type of the contained [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1 General [dcl.decl.general]") in the declarationTD1 is â*derived-declarator-type-list*Tâ,
the type of the [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1 General [dcl.decl.general]") inD is â*derived-declarator-type-list* [*cv-qualifier-seq*](dcl.decl.general#nt:cv-qualifier-seq "9.3.1 General [dcl.decl.general]") pointer toTâ[.](#1.sentence-1)

The[*cv-qualifier*](dcl.decl.general#nt:cv-qualifier "9.3.1 General [dcl.decl.general]")*s* apply to the pointer and not to the object pointed to[.](#1.sentence-2)

Similarly, the optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") ([[dcl.attr.grammar]](dcl.attr.grammar "9.13.1 Attribute syntax and semantics")) appertains to the pointer and not to the object pointed to[.](#1.sentence-3)

[2](#2)

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

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

The declarationsconst int ci = 10, *pc = &ci, *const cpc = pc, **ppc;int i, *p, *const cp = &i; declareci,
a constant integer;pc,
a pointer to a constant integer;cpc,
a constant pointer to a constant integer;ppc,
a pointer to a pointer to a constant integer;i,
an integer;p,
a pointer to integer; andcp,
a constant pointer to integer[.](#2.sentence-1)

The value ofci,cpc,
andcp cannot be changed after initialization[.](#2.sentence-2)

The value ofpc can be changed, and so can the object pointed to bycp[.](#2.sentence-3)

Examples of
some correct operations arei = ci;*cp = ci;
pc++;
pc = cpc;
pc = p;
ppc = &pc;

Examples of ill-formed operations areci = 1; // error ci++; // error*pc = 2; // error cp = &ci; // error cpc++; // error p = pc; // error ppc = &p; // error

Each is unacceptable because it would either change the value of an object declaredconst or allow it to be changed through a cv-unqualified pointer later, for example:*ppc = &ci; // OK, but would make p point to ci because of previous error*p = 5; // clobber ci

â *end example*]

[3](#3)

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

See also [[expr.assign]](expr.assign "7.6.19 Assignment and compound assignment operators") and [[dcl.init]](dcl.init "9.5 Initializers")[.](#3.sentence-1)

[4](#4)

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

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

Forming a pointer to reference type is ill-formed; see [[dcl.ref]](dcl.ref "9.3.4.3 References")[.](#4.sentence-1)

Forming a function pointer type is ill-formed if the function type has[*cv-qualifier*](dcl.decl.general#nt:cv-qualifier "9.3.1 General [dcl.decl.general]")*s* or a [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]");
see [[dcl.fct]](dcl.fct "9.3.4.6 Functions")[.](#4.sentence-2)

Since the address of a bit-field ([[class.bit]](class.bit "11.4.10 Bit-fields")) cannot be taken,
a pointer can never point to a bit-field[.](#4.sentence-3)

â *end note*]
