mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0026377: Passing Handle objects as arguments to functions as non-const reference to base type is dangerous
Operator of cast to non-const reference is declared deprecated to produce compiler warning if used (usually implicitly). OCCT code is updated to avoid that cast, occurring when function accepting non-const reference to handle is called with handle to derived type. For that, local variable of argument type is passed instead, and down-cast is used to get it to desired type after the call. A few occurrences of use of uninitialized variable are corrected.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
@@ -50,8 +51,6 @@ inline void func (const Handle(gp_Pnt)&) {}
|
||||
inline void func (const Handle(gp_XYZ)&) {}
|
||||
inline void func (const Handle(gp_Trsf)&) {}
|
||||
|
||||
inline void gunc (Handle(Geom_Curve)&) {}
|
||||
|
||||
static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
|
||||
Standard_Integer /*theArgNb*/,
|
||||
const char** /*theArgVec*/)
|
||||
@@ -117,10 +116,7 @@ static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
|
||||
func (cLine);
|
||||
#endif
|
||||
|
||||
// passing handle as non-const reference to base type
|
||||
// currently allowed for compatibility
|
||||
gunc (aLine);
|
||||
Handle(Geom_Curve)& aCurve2 = aLine; // cast to base non-const ref
|
||||
const Handle(Geom_Curve)& aCurve2 = aLine; // cast to base const ref
|
||||
|
||||
Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit...
|
||||
|
||||
|
Reference in New Issue
Block a user