...
Code Block | ||||
---|---|---|---|---|
| ||||
void f() noexcept(false) { unsigned char *ptr = new unsigned char; *ptr = 0; // ... delete ptr; } |
Compliant Solution
If the programmer intends to allocate zero bytes of memory (perhaps in order to obtain a unique pointer value that cannot be reused by any other pointer in the program until it is properly released), then instead of attempting to dereference the resulting pointer, the compliant solution is to declare ptr
as a void *
, which cannot be indirected through in a conforming implementation.
...