[Bug libstdc++/81885] operator-> not checked by -D_GLIBCXX_ASSERTIONS

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Aug 18 14:31:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81885

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In fact it's the idiomatic way to get a real pointer from any kind of smart
pointer, e.g. fancy pointers used by allocators (which don't necessarily have a
get member function).

There's even a proposal to standardize a helper utility for doing it, see
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r1.html

It might not be so common for unique_ptr but it's still not dangerous, or
deserving of an assertion. If the returned pointer is dereferenced you'll get a
segfault anyway, so the benefit of an assertion is minimal. It doesn't prevent
any bugs.


More information about the Gcc-bugs mailing list