Files
2025-10-25 03:02:53 +03:00

2.2 KiB

[basic.stc.static]

6 Basics [basic]

6.8 Memory and objects [basic.memobj]

6.8.6 Storage duration [basic.stc]

6.8.6.2 Static storage duration [basic.stc.static]

1

#

All variables which

do not have thread storage duration and

belong to a namespace scope ([basic.scope.namespace]) or are first declared with the static or extern keywords ([dcl.stc])

have static storage duration.

The storage for these entities lasts for the duration of the program ([basic.start.static], [basic.start.term]).

2

#

If a variable with static storage duration has initialization or a destructor with side effects, it shall not be eliminated even if it appears to be unused, except that a class object or its copy/move may be eliminated as specified in [class.copy.elision].

3

#

[Note 1:

The keyword static can be used to declare a block variable ([basic.scope.block]) with static storage duration;[stmt.dcl] and [basic.start.term] describe the initialization and destruction of such variables.

The keyword static applied to a class data member in a class definition gives the data member static storage duration ([class.static.data]).

— end note]