Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit conversion bug in C++11 #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hannesweisbach
Copy link

I'm compiling opencascade oce on macOS 10.15.6 with clang-7 under Nix. clang-7 uses the "gnu++14" language standard for C++ by default, if nothing else is specified. I couldn't find that opencascade oce requests an explicit C++ standard for compilation.
IVtkVTK_ShapeData.cxx contains a narrowing non-constant cast in an initializer lists, which is illegal in C++11 and above. I fixed it by making it an explicit cast:

../src/IVtkVTK/IVtkVTK_ShapeData.cxx:107:28: error: non-constant-expression cannot be narrowed from type 'IVtk_PointId' (aka 'unsigned long') to 'vtkIdType' (aka 'long long') in initializer list [-Wc++11-narrowing]
  vtkIdType aPoints[2] = { thePointId1, thePointId2 };
                           ^~~~~~~~~~~
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:107:28: note: insert an explicit cast to silence this issue
  vtkIdType aPoints[2] = { thePointId1, thePointId2 };
                           ^~~~~~~~~~~
                           static_cast<vtkIdType>( )
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:107:41: error: non-constant-expression cannot be narrowed from type 'IVtk_PointId' (aka 'unsigned long') to 'vtkIdType' (aka 'long long') in initializer list [-Wc++11-narrowing]
  vtkIdType aPoints[2] = { thePointId1, thePointId2 };
                                        ^~~~~~~~~~~
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:107:41: note: insert an explicit cast to silence this issue
  vtkIdType aPoints[2] = { thePointId1, thePointId2 };
                                        ^~~~~~~~~~~
                                        static_cast<vtkIdType>( )
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:28: error: non-constant-expression cannot be narrowed from type 'IVtk_PointId' (aka 'unsigned long') to 'vtkIdType' (aka 'long long') in initializer list [-Wc++11-narrowing]
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                           ^~~~~~~~~~~
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:28: note: insert an explicit cast to silence this issue
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                           ^~~~~~~~~~~
                           static_cast<vtkIdType>( )
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:41: error: non-constant-expression cannot be narrowed from type 'IVtk_PointId' (aka 'unsigned long') to 'vtkIdType' (aka 'long long') in initializer list [-Wc++11-narrowing]
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                                        ^~~~~~~~~~~
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:41: note: insert an explicit cast to silence this issue
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                                        ^~~~~~~~~~~
                                        static_cast<vtkIdType>( )
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:54: error: non-constant-expression cannot be narrowed from type 'IVtk_PointId' (aka 'unsigned long') to 'vtkIdType' (aka 'long long') in initializer list [-Wc++11-narrowing]
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                                                     ^~~~~~~~~~~
../src/IVtkVTK/IVtkVTK_ShapeData.cxx:168:54: note: insert an explicit cast to silence this issue
  vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
                                                     ^~~~~~~~~~~
                                                     static_cast<vtkIdType>( )

IVtkVTK_ShapeData.cxx contains implicit conversion in initializer lists, which is illegal in C++11 and above. Fix it by making it an explicit conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant