История изменений
Исправление a1ba, (текущая версия) :
C23, 6.4.5 String Literals:
Semantics
...
The multibyte character sequence is then used
to initialize an array of static storage duration and length just sufficient to contain the sequence.
Про static storage duration в 6.2.4:
An object whose identifier is declared without the storage-class specifier thread_local, and either
with external or internal linkage or with the storage-class specifier static, has static storage duration.
Its lifetime is the entire execution of the program and its stored value is initialized only once, prior
to program startup.
Короче, лайфтайм строкового литерала – это вся программа, инициализирован он заранее. Только изменять это UB, об этом в том же разделе про строковые литералы написано.
Исходная версия a1ba, :
C23, 6.4.5 String Literals:
Semantics
...
The multibyte character sequence is then used
to initialize an array of static storage duration and length just sufficient to contain the sequence.
Про static storage duration в 6.2.4:
An object whose identifier is declared without the storage-class specifier thread_local, and either
with external or internal linkage or with the storage-class specifier static, has static storage duration.
Its lifetime is the entire execution of the program and its stored value is initialized only once, prior
to program startup.