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

standard header <memory> with mst_orient_normals.h triggers warnings in Visual Studio #4165

Closed
jasjuang opened this issue Aug 20, 2019 · 2 comments
Assignees

Comments

@jasjuang
Copy link
Contributor

jasjuang commented Aug 20, 2019

Issue Details

Please see below minimal code to reproduce the problem

mycpp.cpp

#include <memory> // if I comment out this include, it compiles like usual

#pragma warning(push, 0)
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
#include "CGAL/mst_orient_normals.h"
#include "CGAL/property_map.h"
#pragma warning(pop)

int main(){
  typedef CGAL::Simple_cartesian<double>::Point_3 Point_3;
  typedef CGAL::Simple_cartesian<double>::Vector_3 Normal_3;
  typedef std::pair<Point_3, Normal_3> PointVectorPair;

  std::vector<PointVectorPair> pts;
    
  const int num_neigh = 18;

  CGAL::mst_orient_normals(
      pts,
      num_neigh,
      CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
      normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));

  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

set(CMAKE_TOOLCHAIN_FILE
    $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
    CACHE STRING "")
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_DEFAULT_TRIPLET} CACHE STRING "")

project(Example)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4")

set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/mycpp.cpp)

find_package(CGAL REQUIRED)

add_executable(${PROJECT_NAME} ${PROJECT_SRCS})

target_link_libraries(${PROJECT_NAME} CGAL::CGAL)

and cgal is installed via vcpkg install cgal

For some reason, if I include the standard header <memory> along with mst_orient_normals.h, I will get warnings from the compiler as shown below, but if I don't include <memory> everything works like usual.

1>mycpp.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xutility(2903): error C2220: warning treated as error - no 'object' file generated
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xutility(2917): note: see reference to function template instantiation 'void std::_Fill_unchecked1<_FwdIt,_Ty>(_FwdIt,_FwdIt,const _Ty &,std::false_type)' being compiled
1>        with
1>        [
1>            _FwdIt=unsigned char *,
1>            _Ty=int
1>        ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xutility(2925): note: see reference to function template instantiation 'void std::_Fill_unchecked<_Ty*,int>(_FwdIt,_FwdIt,const int &)' being compiled
1>        with
1>        [
1>            _Ty=unsigned char,
1>            _FwdIt=unsigned char *
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\boost/graph/two_bit_color_map.hpp(61): note: see reference to function template instantiation 'void std::fill<T*,int>(_FwdIt,_FwdIt,const _Ty &)' being compiled
1>        with
1>        [
1>            T=unsigned char,
1>            _FwdIt=unsigned char *,
1>            _Ty=int
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\boost/graph/two_bit_color_map.hpp(57): note: while compiling class template member function 'boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<Property,unsigned __int64>>::two_bit_color_map(size_t,const IndexMap &)'
1>        with
1>        [
1>            Property=CGAL::internal::MST_graph_vertex_properties<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<PointVectorPair>>>>,
1>            IndexMap=boost::vec_adj_list_vertex_id_map<CGAL::internal::MST_graph_vertex_properties<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<PointVectorPair>>>>,unsigned __int64>
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\boost/graph/two_bit_color_map.hpp(100): note: see reference to function template instantiation 'boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<Property,unsigned __int64>>::two_bit_color_map(size_t,const IndexMap &)' being compiled
1>        with
1>        [
1>            Property=CGAL::internal::MST_graph_vertex_properties<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<PointVectorPair>>>>,
1>            IndexMap=boost::vec_adj_list_vertex_id_map<CGAL::internal::MST_graph_vertex_properties<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<PointVectorPair>>>>,unsigned __int64>
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\boost/graph/breadth_first_search.hpp(317): note: see reference to class template instantiation 'boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<Property,unsigned __int64>>' being compiled
1>        with
1>        [
1>            Property=CGAL::internal::MST_graph_vertex_properties<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<PointVectorPair>>>>
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\boost/graph/breadth_first_search.hpp(345): note: see reference to function template instantiation 'void boost::detail::bfs_dispatch<boost::param_not_found>::apply<VertexListGraph,boost::bfs_visitor<CGAL::internal::Propagate_normal_orientation<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,NormalMap,Kernel>>,boost::graph_visitor_t,boost::no_property>(VertexListGraph &,unsigned __int64,const boost::bgl_named_params<boost::bfs_visitor<CGAL::internal::Propagate_normal_orientation<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,NormalMap,Kernel>>,boost::graph_visitor_t,boost::no_property> &,boost::param_not_found)' being compiled
1>        with
1>        [
1>            VertexListGraph=MST_graph,
1>            _Ty=PointVectorPair
1>        ]
1>C:\dev\vcpkg\installed\x64-windows-dev\include\CGAL/mst_orient_normals.h(706): note: see reference to function template instantiation 'void boost::breadth_first_search<MST_graph,boost::bfs_visitor<CGAL::internal::Propagate_normal_orientation<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,NormalMap,Kernel>>,boost::graph_visitor_t,boost::no_property>(const VertexListGraph &,unsigned __int64,const boost::bgl_named_params<boost::bfs_visitor<CGAL::internal::Propagate_normal_orientation<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,NormalMap,Kernel>>,boost::graph_visitor_t,boost::no_property> &)' being compiled
1>        with
1>        [
1>            _Ty=PointVectorPair,
1>            VertexListGraph=MST_graph
1>        ]
1>C:\Users\jasju\Desktop\test\mycpp.cpp(22): note: see reference to function template instantiation 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>> CGAL::mst_orient_normals<std::vector<_Ty,std::allocator<_Ty>>,CGAL::cgal_bgl_named_params<CGAL::Second_of_pair_property_map<PointVectorPair>,CGAL::internal_np::normal_t,CGAL::cgal_bgl_named_params<CGAL::First_of_pair_property_map<PointVectorPair>,CGAL::internal_np::point_t,boost::no_property>>>(PointRange &,unsigned int,const NamedParameters &)' being compiled
1>        with
1>        [
1>            _Ty=PointVectorPair,
1>            PointRange=std::vector<PointVectorPair,std::allocator<PointVectorPair>>,
1>            NamedParameters=CGAL::cgal_bgl_named_params<CGAL::Second_of_pair_property_map<PointVectorPair>,CGAL::internal_np::normal_t,CGAL::cgal_bgl_named_params<CGAL::First_of_pair_property_map<PointVectorPair>,CGAL::internal_np::point_t,boost::no_property>>
1>        ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xutility(2903): warning C4244: '=': conversion from 'const _Ty' to '_Ty', possible loss of data
1>        with
1>        [
1>            _Ty=int
1>        ]
1>        and
1>        [
1>            _Ty=unsigned char
1>        ]
1>Done building project "Example.vcxproj" -- FAILED.

Am I missing a casting for one of the parameters to CGAL::mst_orient_normals? If not, is it a bug in CGAL? Or is the bug in Visual Studio compiler? I find it bizarre that there's some conflict between <memory> and mst_orient_normals.h exclusively in Visual Studio.

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Windows 10
  • Compiler: Visual Studio 2017 (latest 15.9.5)
  • Release or debug mode: Release
  • CGAL version: 4.14
  • Boost version: 1.70
@MaelRL MaelRL added this to the 4.14.1 milestone Aug 20, 2019
@afabri
Copy link
Member

afabri commented Aug 20, 2019

The warning comes from boost, so it is not our "fault". As the compiler stack trace shows it is the call to std::fill(...., 0) which triggers the warning.

If in boost/graph/two_bit_color_map.hpp(61) you replace 0 with (unsigned char)0 the warning goes away.

@sloriot
Copy link
Member

sloriot commented Aug 20, 2019

@afabri are you planning to do a workaround? If not we should close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants