0024252: GCC warnings on breakage of strict-aliasing rules
authorabv <abv@opencascade.com>
Wed, 15 Jan 2014 02:40:18 +0000 (06:40 +0400)
committerbugmaster <bugmaster@opencascade.com>
Mon, 20 Jan 2014 10:45:34 +0000 (14:45 +0400)
Fixed type casts in NCollection maps
Avoid invalid type cast in handling of LDOM text object
Use correct pointer type in callback function of Graphic3d_CGraduatedTrihedron class
Format of printf() simplified in IntPatch_Point.cxx

src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx
src/IntPatch/IntPatch_Point.cxx
src/NCollection/NCollection_DataMap.hxx
src/NCollection/NCollection_DoubleMap.hxx
src/NCollection/NCollection_IndexedDataMap.hxx
src/NCollection/NCollection_IndexedMap.hxx
src/NCollection/NCollection_Map.hxx
src/OpenGl/OpenGl_GraduatedTrihedron.hxx
src/Visual3d/Visual3d_View.cxx
src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx

index 81e5e5e..cea72b4 100644 (file)
 #include <TCollection_ExtendedString.hxx>
 #include <Font_FontAspect.hxx>
 
-typedef void (*minMaxValuesCallback)(void*);
+class Visual3d_View;
+
 class Graphic3d_CGraduatedTrihedron
 {
-  public:
+public:
+  typedef void (*minMaxValuesCallback)(Visual3d_View*);
+public:
     /* Default constructor. Nullifies the view pointer */
     Graphic3d_CGraduatedTrihedron () : xdrawname ( Standard_False ),
     ydrawname ( Standard_False ),
@@ -95,7 +98,7 @@ class Graphic3d_CGraduatedTrihedron
 
     /* Callback function to define boundary box of displayed objects */
     minMaxValuesCallback cbCubicAxes;
-    void* ptrVisual3dView;
+    Visual3d_View* ptrVisual3dView;
 };
 
 const Handle(Standard_Type)& TYPE(Graphic3d_CGraduatedTrihedron);
index d309025..00750ba 100644 (file)
@@ -148,61 +148,26 @@ void IntPatch_Point::Dump() const {
   cout<<"----------- IntPatch_Point : "<<endl;
   Standard_Real u1,v1,u2,v2;
   pt.Parameters(u1,v1,u2,v2);
-#if 0 
-  cout<<"IntSurf_PntOn2S :   Pnt ("<<pt.Value().X()
-    <<","<<pt.Value().Y()<<","<<pt.Value().Z()<<")"<<endl;
-  cout<<" u1:"<<u1;  cout<<" u2:"<<u2;
-  cout<<" v1:"<<v1;
-  cout<<" v2:"<<v2<<endl;
-  cout<<"  para("<<para<<")";
-  cout<<"  mult("<<mult<<")";
-  cout<<"  OnS1("<<onS1<<")";
-  cout<<"  VtxOnS1("<<vtxonS1<<")"<<endl;
-  cout<<"  OnS2("<<onS2<<")";
-  cout<<"  VtxOnS2("<<vtxonS2<<")";
-  cout<<"  prm1("<<prm1<<")";
-  cout<<"  prm2("<<prm2<<")";
-#else
 
-#ifndef DEB //  for porting on linux
   printf("P(%15.10f,%15.10f,%15.10f) UV1(%15.10f,%15.10f)  UV2(%15.10f,%15.10f) (Para:%15.10f)\n",
         (double)(pt.Value().X()),
         (double)(pt.Value().Y()),
         (double)(pt.Value().Z()),
         (double)u1,(double)v1,(double)u2,(double)v2,(double)para);
-  if(onS1)    { printf("*OnS1*  par=%15.10f arc1=%10lu",(double)prm1,
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&arcS1))))
-                      );  }
-  if(vtxonS1) { printf(" *Vtx1*  vtx1=%10lu",
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&vS1))))); } 
-  if(onS1 || vtxonS1) printf("\n");
-  if(onS2)    { printf("*OnS2*  par=%15.10f arc2=%10lu",(double)prm2,
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&arcS2))))); } 
-  if(vtxonS2) { printf(" *Vtx2*  vtx2=%10lu",
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&vS2))))); } 
-  
-#else // debug mode
-  printf("P(%15.10lf,%15.10lf,%15.10lf) UV1(%15.10lf,%15.10lf)  UV2(%15.10lf,%15.10lf) (Para:%15.10lf)\n",
-        (double)(pt.Value().X()),
-        (double)(pt.Value().Y()),
-        (double)(pt.Value().Z()),
-        (double)u1,(double)v1,(double)u2,(double)v2,(double)para);
-  if(onS1)    { printf("*OnS1*  par=%15.10lf arc1=%10lu",(double)prm1,
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&arcS1))))
-                      );  }
-  if(vtxonS1) { printf(" *Vtx1*  vtx1=%10lu",
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&vS1))))); } 
+  if(onS1)
+    printf("*OnS1*  par=%15.10f arc1=%10p", (double)prm1, (void*)arcS1.operator->());
+  if(vtxonS1)
+    printf(" *Vtx1*  vtx1=%10p", (void*)vS1.operator->());
   if(onS1 || vtxonS1) printf("\n");
-  if(onS2)    { printf("*OnS2*  par=%15.10lf arc2=%10lu",(double)prm2,
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&arcS2))))); } 
-  if(vtxonS2) { printf(" *Vtx2*  vtx2=%10lu",
-                      *((long unsigned *)(((Handle_Standard_Transient *)(&vS2))))); } 
-  
-#endif
-  if(onS2 || vtxonS2) printf("\n");
+  if(onS2)
+    printf("*OnS2*  par=%15.10f arc2=%10p", (double)prm2, (void*)arcS2.operator->());
+  if(vtxonS2)
+    printf(" *Vtx2*  vtx2=%10lu", (void*)vS2.operator->());
+
+  if(onS2 || vtxonS2)
+    printf("\n");
   fflush(stdout);
-  
-#endif  
+
   if(onS1 || onS2) { 
     cout<<" tgt:"<<((tgt)? 1 : 0) <<"   mult:"<<((mult)? 1 :0);
     if(onS1) { 
index b678186..b3218e7 100644 (file)
@@ -173,13 +173,10 @@ template < class TheKeyType,
   //! ReSize
   void ReSize (const Standard_Integer N)
   {
-    DataMapNode** newdata = NULL;
-    DataMapNode** dummy   = NULL;
+    NCollection_ListNode** newdata = NULL;
+    NCollection_ListNode** dummy   = NULL;
     Standard_Integer newBuck;
-    if (BeginResize (N, newBuck, 
-                     (NCollection_ListNode**&)newdata, 
-                     (NCollection_ListNode**&)dummy,
-                     this->myAllocator)) 
+    if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
     {
       if (myData1) 
       {
@@ -202,10 +199,7 @@ template < class TheKeyType,
           }
         }
       }
-      EndResize(N,newBuck,
-                (NCollection_ListNode**&)newdata,
-                (NCollection_ListNode**&)dummy,
-                this->myAllocator);
+      EndResize (N, newBuck, newdata, dummy, this->myAllocator);
     }
   }
 
index 372f173..47df450 100644 (file)
@@ -193,13 +193,10 @@ template < class TheKey1Type,
   //! ReSize
   void ReSize (const Standard_Integer N)
   {
-    DoubleMapNode** ppNewData1 = NULL;
-    DoubleMapNode** ppNewData2 = NULL;
+    NCollection_ListNode** ppNewData1 = NULL;
+    NCollection_ListNode** ppNewData2 = NULL;
     Standard_Integer newBuck;
-    if (BeginResize (N, newBuck, 
-                     (NCollection_ListNode**&)ppNewData1, 
-                     (NCollection_ListNode**&)ppNewData2,
-                     this->myAllocator)) 
+    if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator)) 
     {
       if (myData1) 
       {
@@ -216,7 +213,7 @@ template < class TheKey1Type,
               iK2 = Hasher2::HashCode (p->Key2(), newBuck);
               q = (DoubleMapNode*) p->Next();
               p->Next()  = ppNewData1[iK1];
-              p->Next2() = ppNewData2[iK2];
+              p->Next2() = (DoubleMapNode*)ppNewData2[iK2];
               ppNewData1[iK1] = p;
               ppNewData2[iK2] = p;
               p = q;
@@ -224,10 +221,7 @@ template < class TheKey1Type,
           }
         }
       }
-      EndResize(N,newBuck,
-                (NCollection_ListNode**&)ppNewData1,
-                (NCollection_ListNode**&)ppNewData2,
-                this->myAllocator);
+      EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
     }
   }
 
index bf93c9d..d4ed417 100644 (file)
@@ -197,13 +197,10 @@ template < class TheKeyType,
   //! ReSize
   void ReSize (const Standard_Integer N)
   {
-    IndexedDataMapNode** ppNewData1 = NULL;
-    IndexedDataMapNode** ppNewData2 = NULL;
+    NCollection_ListNode** ppNewData1 = NULL;
+    NCollection_ListNode** ppNewData2 = NULL;
     Standard_Integer newBuck;
-    if (BeginResize (N, newBuck, 
-                     (NCollection_ListNode**&)ppNewData1, 
-                     (NCollection_ListNode**&)ppNewData2,
-                     this->myAllocator)) 
+    if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator)) 
     {
       if (myData1) 
       {
@@ -220,7 +217,7 @@ template < class TheKeyType,
               iK2 = ::HashCode (p->Key2(), newBuck);
               q = (IndexedDataMapNode*) p->Next();
               p->Next()  = ppNewData1[iK1];
-              p->Next2() = ppNewData2[iK2];
+              p->Next2() = (IndexedDataMapNode*)ppNewData2[iK2];
               ppNewData1[iK1] = p;
               ppNewData2[iK2] = p;
               p = q;
@@ -228,10 +225,7 @@ template < class TheKeyType,
           }
         }
       }
-      EndResize(N,newBuck,
-                (NCollection_ListNode**&)ppNewData1,
-                (NCollection_ListNode**&)ppNewData2,
-                this->myAllocator);
+      EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
     }
   }
 
index 374c2e4..c510abc 100644 (file)
@@ -187,13 +187,10 @@ template < class TheKeyType,
   //! ReSize
   void ReSize (const Standard_Integer N)
   {
-    IndexedMapNode** ppNewData1 = NULL;
-    IndexedMapNode** ppNewData2 = NULL;
+    NCollection_ListNode** ppNewData1 = NULL;
+    NCollection_ListNode** ppNewData2 = NULL;
     Standard_Integer newBuck;
-    if (BeginResize (N, newBuck, 
-                     (NCollection_ListNode**&)ppNewData1, 
-                     (NCollection_ListNode**&)ppNewData2,
-                     this->myAllocator)) 
+    if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator)) 
     {
       if (myData1) 
       {
@@ -213,7 +210,7 @@ template < class TheKeyType,
               if (p->Key2() > 0) 
               {
                 iK2 = ::HashCode (p->Key2(), newBuck);
-                p->Next2() = ppNewData2[iK2];
+                p->Next2() = (IndexedMapNode*)ppNewData2[iK2];
                 ppNewData2[iK2] = p;
               }
               p = q;
@@ -221,10 +218,7 @@ template < class TheKeyType,
           }
         }
       }
-      EndResize(N,newBuck,
-                (NCollection_ListNode**&)ppNewData1,
-                (NCollection_ListNode**&)ppNewData2,
-                this->myAllocator);
+      EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
     }
   }
 
index ff762f8..c672032 100644 (file)
@@ -177,13 +177,10 @@ template < class TheKeyType,
   //! ReSize
   void ReSize (const Standard_Integer N)
   {
-    MapNode** newdata = 0L;
-    MapNode** dummy = 0L;
+    NCollection_ListNode** newdata = 0L;
+    NCollection_ListNode** dummy = 0L;
     Standard_Integer newBuck;
-    if (BeginResize (N, newBuck, 
-                     (NCollection_ListNode**&)newdata, 
-                     (NCollection_ListNode**&)dummy,
-                     this->myAllocator)) 
+    if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator)) 
     {
       if (myData1) 
       {
@@ -206,10 +203,7 @@ template < class TheKeyType,
           }
         }
       }
-      EndResize(N,newBuck,
-                (NCollection_ListNode**&)newdata,
-                (NCollection_ListNode**&)dummy,
-                this->myAllocator);
+      EndResize (N, newBuck, newdata, dummy, this->myAllocator);
     }
   }
 
index ccb226e..610ff0e 100755 (executable)
@@ -21,6 +21,7 @@
 #include <OpenGl_Text.hxx>
 #include <Graphic3d_CGraduatedTrihedron.hxx>
 
+class Visual3d_View;
 class OpenGl_View;
 
 class OpenGl_GraduatedTrihedron : public OpenGl_Element
@@ -73,8 +74,8 @@ protected:
   TEL_COLOUR myXColor;
   TEL_COLOUR myYColor;
   TEL_COLOUR myZColor;
-  minMaxValuesCallback myCbCubicAxes;
-  void* myPtrVisual3dView;
+  Graphic3d_CGraduatedTrihedron::minMaxValuesCallback myCbCubicAxes;
+  Visual3d_View* myPtrVisual3dView;
 
 public:
 
index ab03d78..6872ba6 100644 (file)
@@ -3021,22 +3021,20 @@ void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
 
 }
 
-Standard_Boolean checkFloat(const Standard_Real value)
+static Standard_Boolean checkFloat(const Standard_Real value)
 {
     return value > -FLT_MAX && value < FLT_MAX;
 }
 
-void SetMinMaxValuesCallback(void* Visual3dView)
+static void SetMinMaxValuesCallback(Visual3d_View* theView)
 {
     Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
-
-    Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
-    view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
+    theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
 
     if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
         checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
     {
-        Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
+        Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
         driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
                                                (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
     }
index 0628bc5..0f1d384 100644 (file)
@@ -344,8 +344,7 @@ void XmlMNaming_NamedShapeDriver::ReadShapeSection
          aNode = anElement.getNextSibling())
     {
       if (aNode.getNodeType() == LDOM_Node::TEXT_NODE) {
-        LDOM_Text aText = (LDOM_Text&) aNode;
-        LDOMString aData = aText.getData();
+        LDOMString aData = aNode.getNodeValue();
        #ifdef USE_STL_STREAM
         std::stringstream aStream (std::string(aData.GetString()));
        #else