This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/14493] std::bad_alloc::what() does not explain what happened
- From: "gdr at cs dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2007 01:30:13 -0000
- Subject: [Bug libstdc++/14493] std::bad_alloc::what() does not explain what happened
- References: <bug-14493-5724@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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