[expr.sub]

# 7 Expressions [[expr]](./#expr)

## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.sub)

### 7.6.1 Postfix expressions [[expr.post]](expr.post#expr.sub)

#### 7.6.1.2 Subscripting [expr.sub]

[1](#1)

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

A [*subscript expression*](#def:expression,subscript "7.6.1.2 Subscripting [expr.sub]") is a postfix expression
followed by square brackets containing
a possibly empty, comma-separated list of [*initializer-clause*](dcl.init.general#nt:initializer-clause "9.5.1 General [dcl.init.general]")*s* that constitute the arguments to the subscript operator[.](#1.sentence-1)

The [*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") and
the initialization of the object parameter ([[dcl.fct]](dcl.fct "9.3.4.6 Functions")) of
any applicable subscript operator function ([[over.sub]](over.sub "12.4.5 Subscripting")) is sequenced before
each expression in the [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") and also before
any default argument ([[dcl.fct.default]](dcl.fct.default "9.3.4.7 Default arguments"))[.](#1.sentence-2)

The initialization of a non-object parameter of
a subscript operator function S,
including every associated value computation and side effect,
is indeterminately sequenced with respect to that of
any other non-object parameter of S[.](#1.sentence-3)

[2](#2)

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

With the built-in subscript operator,
an [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") shall be present,
consisting of a single [*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19 Assignment and compound assignment operators [expr.assign]")[.](#2.sentence-1)

One of the expressions shall be a glvalue of type âarray ofTâ or a prvalue of type âpointer
to Tâ and the other shall be a prvalue of unscoped enumeration or integral type[.](#2.sentence-2)

The result is of type âTâ[.](#2.sentence-3)

The type âTâ shall be a completely-defined object type[.](#2.sentence-4)[48](#footnote-48 "This is true even if the subscript operator is used in the following common idiom: &amp;x[0].")

The expression E1[E2] is identical (by definition) to*((E1)+(E2)),
except that in the case of an array operand, the result is an lvalue
if that operand is an lvalue and an xvalue otherwise[.](#2.sentence-5)

[3](#3)

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

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

Despite its asymmetric appearance, subscripting is a commutative
operation except for sequencing[.](#3.sentence-1)

See [[expr.unary]](expr.unary "7.6.2 Unary expressions") and [[expr.add]](expr.add "7.6.6 Additive operators") for details of * and+ and [[dcl.array]](dcl.array "9.3.4.5 Arrays") for details of array types[.](#3.sentence-2)

â *end note*]

[48)](#footnote-48)[48)](#footnoteref-48)

This
is true even if the subscript operator is used in the following common idiom:&x[0][.](#footnote-48.sentence-1)
