Стандарт говорит, что значения указателей меняются при освобождении памяти на невалидные ([basic.stc]/4):



When the end of the duration of a region of storage is reached, the values of all pointers representing the address of any part of that region of storage become invalid pointer values.



Но как могут меняться значения константных указателей? Типа


int* const pi = new int{}; // pi — указатель на об'ект типа int
delete pi; // меняет значение pi на invalid pointer value?!


Так делать — UB из-за [intro.execution]/4?



Certain other operations are described in this document as undefined (for example, the effect of attempting
to modify a const object).










 , ,






URL записи