[osg-users] OpenSceneGraph-3.4.0-rc6 tagged

Robert Osfield robert.osfield at gmail.com
Thu Jul 23 03:32:54 PDT 2015


Hi Pjotr,

Thanks for testing with VS2015 and reporting the warnings.  I don't have
VS2015 so can't test any fixes myself, could you have a bash at fixing the
warnings and send me the changes, I can then review.

Currently I'm working on addressing warnings generated by clang 3.6, it's
pretty strict but hasn't reported the same warnings as VS2015.

Cheers,
Robert.

On 23 July 2015 at 11:12, Pjotr Svetachov <pjotrsvetachov at gmail.com> wrote:

> Hi Robert,
>
> Testing with the newly released VS2015 produced these 4 warnings for each
> file that includes (directly or indirectly) osg/GraphicsThread this will
> lead to hundreds of warnings:
> 1>I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(55):
> warning C4589: Constructor of abstract class 'osg::Operation' ignores
> initializer for virtual base class 'osg::Referenced'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(55):
> note: virtual base classes are only initialized by the most-derived type
> 1>I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(81):
> warning C4589: Constructor of abstract class 'osg::Operation' ignores
> initializer for virtual base class 'osg::Referenced'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(81):
> note: virtual base classes are only initialized by the most-derived type
> 1>I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(85):
> warning C4589: Constructor of abstract class 'osg::Operation' ignores
> initializer for virtual base class 'osg::Referenced'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/OperationThread(85):
> note: virtual base classes are only initialized by the most-derived type
> 1>I:\Libraries\OpenSceneGraphTrunk\include\osg/GraphicsThread(45): warning
> C4589: Constructor of abstract class 'osg::GraphicsOperation' ignores
> initializer for virtual base class 'osg::Referenced'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/GraphicsThread(45): note:
> virtual base classes are only initialized by the most-derived type
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/GraphicsThread(45): note:
> This diagnostic occurred in the compiler generated function
> 'osg::GraphicsOperation::GraphicsOperation(const osg::GraphicsOperation &)'
>
> Trying to find out what is really happening I stumbled on this:
>
> http://stackoverflow.com/questions/10534228/order-of-constructor-call-in-virtual-inheritance
>
> The first three warnings come from this:
> The problem is that the Operation class is virtually inheriting from the
> class Referenced. The constructors and copy constructors of the class
> Operation call Referenced(true). Now, with virtual inheritance the
> constructors of virtual base classes are always called from the most
> derived class. Now what Visual Studio is complaining about is that
> Operations is a abstract class so you can not construct an instance of it
> directly. You need to inherit from it, implement the abstract methods and
> construct the derived class. So the call to Referenced(true) will never
> happen inside the Operation constructors. Instead you need to add this call
> to the most derived classes of Operation. If you don't do this it will call
> the default constructor Referenced::Referenced() instead of
> Referenced::Referenced(true).
> I did a search to see whats inheriting from Operation and found a few
> cases. For example BlockAndFlushOperation and
> ReleaseContext_Block_MakeCurrentOperation do not call Referenced(true) in
> their constructors so then the default constructor Referenced() is called.
>
> The 4th warning comes from that visual studio makes a default constructor
> for GraphicsOperation that calls Referenced() and then complains about it,
> this is probably a bug in vs2015, see also:
> https://connect.microsoft.com/VisualStudio/feedback/details/1570496/vs-2015-generates-a-copy-constructor-and-then-complains-about-it
>
> The same is happening for the class ViewerBase because it is using virtual
> inheritance to derive from Object and calling Object(true) from the
> constructor.
> For ViewerBase I even got an error:
> 1>I:\Libraries\OpenSceneGraphTrunk\include\osgViewer/ViewerBase(340):
> error C2249: 'osg::Object::operator =': no accessible path to private
> member declared in virtual base 'osg::Object'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/Object(238): note: see
> declaration of 'osg::Object::operator ='
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osg/Object(56): note: see
> declaration of 'osg::Object'
> 1>  I:\Libraries\OpenSceneGraphTrunk\include\osgViewer/ViewerBase(340):
> note: This diagnostic occurred in the compiler generated function
> 'osgViewer::ViewerBase &osgViewer::ViewerBase::operator =(const
> osgViewer::ViewerBase &)'
> But this looks like the bug in visual studio from above but this time it
> makes a default copy operator for ViewerBase that tries to call the private
> copy operator of Object from the generated default copy operator. It might
> be an bug in the compiler or it might be by a genuine error (I don't know
> the specs of c++ that well:) ) but a workaround for this error is to add:
>
> Code:
>
> private:
> ViewerBase& operator = (const ViewerBase&) { return *this; }
>
>
>
> At the end of the ViewerBase class. (At least if that is the intended
> behavior)
>
>
> Cheers,
> Pjotr
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64443#64443
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150723/33437b33/attachment-0003.htm>


More information about the osg-users mailing list