0

I often face warning like this using VSCode and CMake when compiling my code:

C:\Program Files\Microsoft Visual Studio\2022\ 
       Community\VC\Tools\MSVC\14.31.31103\include\xuti 
       lity(136,48): warning C4244: 'initializing': con 
       version from 'const double' to '_Ty', possible l 
       oss of data [C:\IBOIS57\_Code\Software\Python\co 
       mpas_wood\backend\build_win\wood.vcxproj]    

I clearly understand that there is an issue with my code when types are not the same. But this error points somewhere that is not my code. Is it possible to show where this warning is coming from?

I am already printing preprocessing and compilation messages in verbose mode.

This is the full message:

-- Build files have been written to: C:/IBOIS57/_Code/Software/Python/compas_wood/backend/build_win
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/IBOIS57/_Code/Software/Python/compas_wood/backend/CMakeLists.txt
  clipper.engine.cpp
  clipper.offset.cpp
  Generating Code...
  Clipper2.vcxproj -> C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\Release\Clipper2.lib
  Building Custom Rule C:/IBOIS57/_Code/Software/Python/compas_wood/backend/CMakeLists.txt
  stb_image.cpp
  stb_image_write.cpp
  Generating Code...
  STB.vcxproj -> C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\Release\STB.lib
  Building Custom Rule C:/IBOIS57/_Code/Software/Python/compas_wood/backend/CMakeLists.txt
  imgui_demo.cpp
  imgui_draw.cpp
  imgui_tables.cpp
  imgui_widgets.cpp
  imgui.cpp
  imgui_impl_opengl3.cpp
  imgui_impl_glfw.cpp
  Generating Code...
  imgui_lib.vcxproj -> C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\Release\imgui_lib.lib
  Building Custom Rule C:/IBOIS57/_Code/Software/Python/compas_wood/backend/CMakeLists.txt
  cmake_pch.cxx
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(135,1): warning C4267: 'initializing': conversion from 'siz
e_t' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(134): message : see reference to function template instanti
ation '_Ty *std::construct_at<_Objty,unsigned __int64,void>(_Ty *const ,unsigned __int64 &&) noexcept(<expr>)' being compiled 
[C:\IBOIS57\_Code\Software\Pytho
n\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=int,
              _Objty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,unsigned __int64>(_Alloc &,_Objty *const ,unsigned __int64 &&)' being compiled [C:\IBOIS57\_Co
de\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<int>,
              _Ty=int,
              _Objty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,unsigned __int64>(_Alloc &,_Objty *const ,unsigned __int64 &&)' being compiled [C:\IBOIS57\_Co
de\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<int>,
              _Ty=int,
              _Objty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(620): message : see reference to function template instantiat
ion '_Ty &std::vector<_Ty,std::allocator<_Ty>>::_Emplace_back_with_unused_capacity<unsigned __int64>(unsigned __int64 &&)' being compiled [C:\IBOIS57\_Code\So
ftware\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=int
          ]
C:\IBOIS57\_Code\Software\Python\compas_wood\backend\src/viewer/include/opengl/opengl_triangulation.h(151): message : see reference to function template insta
ntiation '_Ty &std::vector<_Ty,std::allocator<_Ty>>::emplace_back<unsigned __int64>(unsigned __int64 &&)' being compiled [C:\IBOIS57\_Code\Software\Python\com
pas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(673,1): warning C4267: 'initializing': conversion from 'size
_t' to '_Objty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Objty=int
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(135,50): warning C4244: 'initializing': conversion from '_T
y' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=double
          ]
          and
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(134): message : see reference to function template instanti
ation '_Ty *std::construct_at<_Objty,double,void>(_Ty *const ,double &&) noexcept(<expr>)' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\backen
d\build_win\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,double>(_Alloc &,_Objty *const ,double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\c
ompas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,double>(_Alloc &,_Objty *const ,double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\c
ompas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(620): message : see reference to function template instantiat
ion '_Ty &std::vector<_Ty,std::allocator<_Ty>>::_Emplace_back_with_unused_capacity<double>(double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\compas
_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=float
          ]
C:\IBOIS57\_Code\Software\Python\compas_wood\backend\src\wood\include\cgal_mesh_util.h(606): message : see reference to function template instantiation '_Ty &
std::vector<_Ty,std::allocator<_Ty>>::emplace_back<double>(double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcx
proj]
          with
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(680,47): warning C4244: 'initializing': conversion from '_Ty
' to '_Objty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=double
          ]
          and
          [
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(135,50): warning C4244: 'initializing': conversion from 'co
nst double' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]     
          with
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(134): message : see reference to function template instanti
ation '_Ty *std::construct_at<_Objty,const double&,void>(_Ty *const ,const double &) noexcept(<expr>)' being compiled [C:\IBOIS57\_Code\Software\Python\compas
_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double&>(_Alloc &,_Objty *const ,const double &)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double&>(_Alloc &,_Objty *const ,const double &)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(620): message : see reference to function template instantiat
ion '_Ty &std::vector<_Ty,std::allocator<_Ty>>::_Emplace_back_with_unused_capacity<const double&>(const double &)' being compiled [C:\IBOIS57\_Code\Software\P
ython\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=float
          ]
C:\IBOIS57\_Code\Software\Python\compas_wood\backend\src\wood\include\cgal_mesh_util.h(710): message : see reference to function template instantiation '_Ty &
std::vector<_Ty,std::allocator<_Ty>>::emplace_back<const double&>(const double &)' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_
win\wood.vcxproj]
          with
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(680,47): warning C4244: 'initializing': conversion from 'con
st double' to '_Objty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]   
          with
          [
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(135,50): warning C4244: 'initializing': conversion from '_T
y' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=const double
          ]
          and
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(134): message : see reference to function template instanti
ation '_Ty *std::construct_at<_Objty,const double,void>(_Ty *const ,const double &&) noexcept(<expr>)' being compiled [C:\IBOIS57\_Code\Software\Python\compas
_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double>(_Alloc &,_Objty *const ,const double &&)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double>(_Alloc &,_Objty *const ,const double &&)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(620): message : see reference to function template instantiat
ion '_Ty &std::vector<_Ty,std::allocator<_Ty>>::_Emplace_back_with_unused_capacity<const double>(const double &&)' being compiled [C:\IBOIS57\_Code\Software\P
ython\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=float
          ]
C:\IBOIS57\_Code\Software\Python\compas_wood\backend\src\wood\include\cgal_mesh_util.h(755): message : see reference to function template instantiation '_Ty &
std::vector<_Ty,std::allocator<_Ty>>::emplace_back<const double>(const double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_
win\wood.vcxproj]
          with
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(680,47): warning C4244: 'initializing': conversion from '_Ty
' to '_Objty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=const double
          ]
          and
          [
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(136,48): warning C4244: 'initializing': conversion from '_T
y' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=double
          ]
          and
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(673): message : see reference to function template instantia
tion '_Ty *std::construct_at<_Objty,double,void>(_Ty *const ,double &&) noexcept' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_w
in\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,double>(_Alloc &,_Objty *const ,double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\c
ompas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,double>(_Alloc &,_Objty *const ,double &&)' being compiled [C:\IBOIS57\_Code\Software\Python\c
ompas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(136,48): warning C4244: 'initializing': conversion from 'co
nst double' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]     
          with
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(673): message : see reference to function template instantia
tion '_Ty *std::construct_at<_Objty,const double&,void>(_Ty *const ,const double &) noexcept' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\bac
kend\build_win\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double&>(_Alloc &,_Objty *const ,const double &)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double&>(_Alloc &,_Objty *const ,const double &)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(136,48): warning C4244: 'initializing': conversion from '_T
y' to '_Ty', possible loss of data [C:\IBOIS57\_Code\Software\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Ty=const double
          ]
          and
          [
              _Ty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(673): message : see reference to function template instantia
tion '_Ty *std::construct_at<_Objty,const double,void>(_Ty *const ,const double &&) noexcept' being compiled [C:\IBOIS57\_Code\Software\Python\compas_wood\bac
kend\build_win\wood.vcxproj]
          with
          [
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double>(_Alloc &,_Objty *const ,const double &&)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiat
ion 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,const double>(_Alloc &,_Objty *const ,const double &&)' being 
compiled [C:\IBOIS57\_Code\Softw
are\Python\compas_wood\backend\build_win\wood.vcxproj]
          with
          [
              _Alloc=std::allocator<float>,
              _Ty=float,
              _Objty=float
          ]
  main.cpp
  wood_globals.cpp
  clipper_util.cpp
  wood_element.cpp
  wood_joint.cpp
  wood_test.cpp
  wood_main.cpp
  viewer_wood.cpp
  wood_xml.cpp
  cgal_mesh_boolean.cpp
  opengl_globals_geometry.cpp
  opengl_globals.cpp
  Generating Code...
Petras Vestartas
  • 136
  • 1
  • 3
  • 10
  • 2
    Are you really asking to fix the error in your not shown code? – 273K Jan 02 '23 at 18:11
  • 1
    If you really want an answer to your problem you should post the entire chain of the error message with a [*minimal,reproducable example*](https://stackoverflow.com/help/minimal-reproducible-example). – Captain Obvlious Jan 02 '23 at 18:14
  • This is a problem with the Visual Studio compiler and its own libraries, you could safely ignore this. It silence the warning, you can temporarily disable it around including the system header files. – Lindydancer Jan 02 '23 at 19:38
  • 2
    @Lindydancer -- you haven't seen the code that produces this warning, so you cannot possibly know that it's a problem in the library code or that it's safe to ignore it. – Pete Becker Jan 02 '23 at 20:07
  • There was more to the error message than what's shown in the question. The quoted part of the error message tells you where the problem was **detected**. tThere are a bunch of other citations showing the call chain that led to this warning; you have to look at them to see what in your code triggered the warning. – Pete Becker Jan 02 '23 at 20:08
  • I updated the code to the full message – Petras Vestartas Jan 03 '23 at 15:44
  • 1
    see https://stackoverflow.com/questions/4001736/whats-up-with-the-thousands-of-warnings-in-standard-headers-in-msvc-wall – Bernd Jan 03 '23 at 18:26

0 Answers0