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

C++17 mode #396

Closed
henryiii opened this issue Jan 9, 2020 · 2 comments
Closed

C++17 mode #396

henryiii opened this issue Jan 9, 2020 · 2 comments
Milestone

Comments

@henryiii
Copy link
Collaborator

henryiii commented Jan 9, 2020

We have a warning or two in C++17 mode on windows, and macOS 10.14 does not support C++17 mode - we might be able to get this to pass by checking a feature macro instead of C++ mode for filesystem. See #394.

@henryiii henryiii added this to the v1.9 milestone Jan 9, 2020
@phlptp
Copy link
Collaborator

phlptp commented Jan 9, 2020

Here is the visual studio warning

45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(65,17): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message : see reference to function template instantiation 'std::_Optional_destruct_base<_Ty,true>::_Optional_destruct_base<double&>(std::in_place_t,double &)' being compiled
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         with
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         [
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :             _Ty=int
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         ]
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message : see reference to function template instantiation 'std::_Optional_destruct_base<_Ty,true>::_Optional_destruct_base<double&>(std::in_place_t,double &)' being compiled
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         with
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         [
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :             _Ty=int
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(215): message :         ]
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message : see reference to function template instantiation 'std::_Optional_construct_base<_Ty>::_Optional_construct_base<double&>(std::in_place_t,double &)' being compiled
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         with
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         [
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :             _Ty=int
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         ]
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message : see reference to function template instantiation 'std::_Optional_construct_base<_Ty>::_Optional_construct_base<double&>(std::in_place_t,double &)' being compiled
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         with
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         [
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :             _Ty=int
45>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\optional(201): message :         ]
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message : see reference to function template instantiation 'std::optional<int>::optional<double&,0>(_Ty2)' being compiled
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         with
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         [
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :             _Ty2=double &
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         ]
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message : see reference to function template instantiation 'std::optional<int>::optional<double&,0>(_Ty2)' being compiled
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         with
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         [
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :             _Ty2=double &
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(702): message :         ]
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(766): message : see reference to function template instantiation 'bool CLI::detail::lexical_cast<T,0>(const std::string &,T &)' being compiled
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(766): message :         with
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(766): message :         [
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(766): message :             T=std::optional<int>
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(766): message :         ]
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message : see reference to function template instantiation 'bool CLI::detail::lexical_assign<T,XC,0>(const std::string &,T &)' being compiled
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message :         with
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message :         [
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message :             T=std::optional<int>,
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message :             XC=std::optional<int>
45>C:\Users\phlpt\Documents\CLI11\include\CLI/TypeTools.hpp(804): message :         ]
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message : see reference to function template instantiation 'bool CLI::detail::lexical_conversion<AssignTo,ConvertTo,0>(const std::vector<std::string,std::allocator<_Ty>> &,T &)' being compiled
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :         with
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :         [
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :             AssignTo=std::optional<int>,
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :             ConvertTo=std::optional<int>,
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :             _Ty=std::string,
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :             T=std::optional<int>
45>C:\Users\phlpt\Documents\CLI11\include\CLI/App.hpp(597): message :         ]
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(52): message : see reference to function template instantiation 'CLI::Option *CLI::App::add_option<std::optional<int>,AssignTo,0>(std::string,AssignTo &,std::string,bool)' being compiled
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(52): message :         with
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(52): message :         [
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(52): message :             AssignTo=std::optional<int>
45>C:\Users\phlpt\Documents\CLI11\tests\OptionalTest.cpp(52): message :         ]

It has to do with the Optional test of optional I think what is happening is that the optional type can take a double as part of the constructor just fine (at least in Visual Studio) thus the type detection in CLI11 is allowing the more flexible type through lexical cast and we get a warning on double truncation.

We can remove the warning on visual studio, or just for that case,
or we can just ignore it.

I don't really want to change the test since that would change the nature of the test itself as that was intended to test the automatic detection. If this warning was in actual code I would recommend using the explicit version of add_option with the template arguments.

Longer term I have some ideas on improving the type detection for add_option so that would resolve the issue but that is something for 2.0.

@henryiii
Copy link
Collaborator Author

henryiii commented Jan 9, 2020

I'm fine with ignoring the warning, but we should do so, since otherwise we can't run the test suite on Windows.

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

No branches or pull requests

2 participants