This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11159] erroneous warning in copy ctor with virtual inheritance
- From: "jwakely dot gcc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Nov 2007 13:27:20 -0000
- Subject: [Bug c++/11159] erroneous warning in copy ctor with virtual inheritance
- References: <bug-11159-5779@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from jwakely dot gcc at gmail dot com 2007-11-14 13:27 -------
(In reply to comment #10)
>
> I do not have access to std::basic_ios from MyStream. Solution here?
Yes you do. The warning can be prevented by initialising the virtual base:
MyStream() : std::ios(), std::ostringstream() {}
However in general I agree that the warnings are bogus. If there is no suitable
constructor for the virtual base you get an error, so the warning is only
issued when the behaviour is perfectly well-defined, and in many cases probably
exactly what the author of the code wanted.
Even the text of the warning is misleading. Why "should" it be explicitly
initialised, when the standard says it will be implicitly initialised if a
suitable default constructor exists?
If you want to use a non-default constructor for the virtual base then you need
to call it explicitly. But if the default constructor is what you want, why
should you have to do extra work?
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11159