This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11159] erroneous warning in copy ctor with virtual inheritance



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]