[poly_collection][VS 2017] Potential compiler bug
Hi, Boost.PolyCollection tests have started to cycle and I found VS 2017 aka MSVC 14.1 fails at test_algorithm.cpp: http://tinyurl.com/yb4zdkys whereas this test compiles and runs OK with VS 2015 aka MSVC 4.0 (_MSC_FULL_VER = 190023026). I've distilled down the problem to this test case: #include <algorithm> #include <utility> template<typename... Ts> struct all_of { template<typename... Args> auto operator()(Args&&... args)const-> decltype(std::all_of<Ts...>(std::forward<Args>(args)...)) { return std::all_of<Ts...>(std::forward<Args>(args)...); } }; int main() { int x; all_of<> alg; alg(&x,&x,[](int){return true;}); } which works fine with GCC and VS 2015 but fails in webcompiler.cloudapp.net with Compiled with /EHsc /nologo /W4 /c main.cpp main.cpp(9): error C3546: '...': there are no parameter packs available to expand main.cpp(18): note: see reference to class template instantiation 'all_of<>' being compiled (_MSC_FULL_VER = 191125331, which I think is VS 2017.3 or something). This looks like a regression to me. Deleting the ->decltype(...) bit makes the problem go away but I need to stay within C+11. * Can someone (STL?) confirm this is indeed a compiler bug? * Any rewording of the code that might be generally applicable to C++11 so that I don't have to include a specific workaround for VS 2017? Thank you, Joaquín M López Muñoz
Yep, looks like a compiler bug. Reduced (see below) and filed as VSO#445619. This works if you call std::all_of() without explicit template arguments - I'm not sure why you were trying to provide them. Reduced repro: C:\Temp>type meow.cpp namespace Std { template <typename InIt, typename Pr> bool AllOf(InIt, InIt, Pr) { return true; } template <typename T> struct RemoveRef { using type = T; }; template <typename T> struct RemoveRef<T&> { using type = T; }; template <typename T> struct RemoveRef<T&&> { using type = T; }; template <typename T> constexpr T&& Forward(typename RemoveRef<T>::type& t) noexcept { return static_cast<T&&>(t); } } template <typename... Ts> struct Meow { template <typename... Args> auto operator()(Args&&... args) const -> decltype(Std::AllOf<Ts...>(Std::Forward<Args>(args)...)) { return Std::AllOf<Ts...>(Std::Forward<Args>(args)...); } }; int main() { Meow<> alg; alg(10, 10, 3.14); } C:\Temp>cl /EHsc /nologo /W4 meow.cpp meow.cpp meow.cpp(23): error C3546: '...': there are no parameter packs available to expand meow.cpp(29): note: see reference to class template instantiation 'Meow<>' being compiled C:\Temp>clang-cl /EHsc /nologo /W4 meow.cpp C:\Temp> Thanks, STL -----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Joaquin M López Muñoz via Boost Sent: Friday, June 2, 2017 9:02 AM To: boost@lists.boost.org Cc: Joaquin M López Muñoz <joaquinlopezmunoz@gmail.com> Subject: [boost] [poly_collection][VS 2017] Potential compiler bug Hi, Boost.PolyCollection tests have started to cycle and I found VS 2017 aka MSVC 14.1 fails at test_algorithm.cpp: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftinyurl.com%2Fyb4zdkys&data=02%7C01%7Cstl%40exchange.microsoft.com%7Cf1f8085f63704a3d13f408d4a9d0d4b0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636320161769104283&sdata=lmdoZRJng1ZpCUv9w16gOsR7UAD%2BCuIcmYeUDN8ah50%3D&reserved=0 whereas this test compiles and runs OK with VS 2015 aka MSVC 4.0 (_MSC_FULL_VER = 190023026). I've distilled down the problem to this test case: #include <algorithm> #include <utility> template<typename... Ts> struct all_of { template<typename... Args> auto operator()(Args&&... args)const-> decltype(std::all_of<Ts...>(std::forward<Args>(args)...)) { return std::all_of<Ts...>(std::forward<Args>(args)...); } }; int main() { int x; all_of<> alg; alg(&x,&x,[](int){return true;}); } which works fine with GCC and VS 2015 but fails in webcompiler.cloudapp.net with Compiled with /EHsc /nologo /W4 /c main.cpp main.cpp(9): error C3546: '...': there are no parameter packs available to expand main.cpp(18): note: see reference to class template instantiation 'all_of<>' being compiled (_MSC_FULL_VER = 191125331, which I think is VS 2017.3 or something). This looks like a regression to me. Deleting the ->decltype(...) bit makes the problem go away but I need to stay within C+11. * Can someone (STL?) confirm this is indeed a compiler bug? * Any rewording of the code that might be generally applicable to C++11 so that I don't have to include a specific workaround for VS 2017? Thank you, Joaquín M López Muñoz _______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.boost.org%2Fmailman%2Flistinfo.cgi%2Fboost&data=02%7C01%7Cstl%40exchange.microsoft.com%7Cf1f8085f63704a3d13f408d4a9d0d4b0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636320161769104283&sdata=Uf8QTdypFQ0s227EVsok%2B66sPMS7pIruvslYRQnzESo%3D&reserved=0
participants (2)
-
Joaquin M López Muñoz
-
Stephan T. Lavavej