I had read the following rule and I\'ve been trying to write an example, which reflects one. The rule is from 3.8/5 N3797:
Before the lifetime of an o
You asked:
Is it true that in the case //1 is well-formed and doesn't cause any UB?
The parts of the standard you quoted does not mention anything about it.
You also asked:
but //2 produced segmentation fault, which is UB?
The parts of the standard you quoted does not correspond to this particular behavior. You are seeing UB because of where p
points. It points to memory that does not hold a valid object.