[Bug libstdc++/14493] std::bad_alloc::what() does not explain what happened
------- Comment #21 from gdr at cs dot tamu dot edu 2007-01-30 01:30 -------
Subject: Re: std::bad_alloc::what() does not explain what happened
"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| What do you mean by "incorrect"?!? If you subclass, either you
| provide your own what(), or you get the what() provided by the base
| class, which is implementation defined and, very reasonably,
| "std::bad_cast" for class bad_cast, and so on...
Paolo is technically right: what() is a virtual member function; so
one should not derive from those classes and except that what()
returned something they did not define or we did not promise.
I suspect Andrew Pinski's point might be that what() could return a
string that represents the name of the most derived type of the
exception. But, nothing so far forces to do that. A reasonable
definition is to what Paolo suggest, with clear documentation (that
mentions this).
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14493
------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
Reply to: