File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 178178\end {codeblock }
179179\end {example }
180180
181- \pnum
182- \ubxref {lifetime.outside.pointer.static.cast }
183- For a pointer pointing to an object outside of its lifetime, behavior is
184- undefined if the pointer is used as the operand of a
185- \tcode {static_cast}, except when the conversion
186- is to pointer to \cv {}~\tcode {void}, or to pointer to \cv {}~\tcode {void}
187- and subsequently to pointer to
188- \cv {}~\tcode {char},
189- \cv {}~\tcode {unsigned char}, or
190- \cv {}~\tcode {std::byte}\iref {cstddef.syn }.
191-
192- \pnum
193- \begin {example }
194- \begin {codeblock }
195- struct B {};
196- struct D : B {};
197- void f()
198- {
199- D d;
200- B* bp = &d;
201- d.~D();
202- void* vp = bp; // OK
203- D* dp = static_cast<D*>(bp); // undefined behavior
204- }
205- \end {codeblock }
206- \end {example }
207-
208181\pnum
209182\ubxref {lifetime.outside.pointer.dynamic.cast }
210183For a pointer pointing to an object outside of its lifetime, behavior is
You can’t perform that action at this time.
0 commit comments