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

--- Comment #2 from Jonny Grant <jg at jguk dot org> ---
(In reply to Jonathan Wakely from comment #1)
> Why are you suggesting adding a check in two places when the first one just
> calls the second one?

Feels clearer in the callstack if operator= throws when nullptr is passed.
Likewise if assign() is called with nullptr it looks clearer if the throw is
from there. Of course it may be enough just to put it in assign() if that is
your preference.

I was taught to validate parameters at University. Personally I always follow
defensive programming approaches to avoid crashes. So I would check parameters
on all interface methods and operators. I would rely on the compiler to remove
any unnecessary duplicate sanity checks.

> What would be the point of _GLIBCXX_DEBUG_PEDASSERT when there's already a
> debug assertion there? Compiling with _GLIBCXX_DEBUG will already abort.

I don't see a debug assertion for _GLIBCXX_DEBUG_PEDASSERT  could you point out
the file and line number to me please.

Just compiled with -D_GLIBCXX_DEBUG but I don't get any abort, just the same
SEGV
https://godbolt.org/z/rjYG8Yrnh

> 
> I don't see the point of adding anything to char_traits at all. It's a very
> low-level interface and you probably shouldn't be (and aren't) using it
> directly anyway.

Sounds reasonable, it's true I'm not using char_traits.

Reply via email to