3.8/4 says:
A program may end the lifetime of any object by reusing the storage which the object occupies
...
For an object of a class type with a non-trivial destructor, the program is not required to call the
destructor explicitly before the storage which the object occupies is reused or released; however
...
any program that depends on the side effects produced by the destructor has undefined behavior.
Suppose I have the following program:
#include <stdio.h>
#include <memory>
int x;
struct y { ~y() { ++x; } };
void f() { y z; new(&z) y; }
int main() { f(); printf("%d\n", x); }
Questions:
1) What does the Standard mean when it says "depends on the side effects"? 1.9/12 says that
side effects are changes in the state of the execution environment; what is a side effect that a
program does not depend on? How can we examine a program to determine whether it depends