Last active
December 17, 2017 13:39
-
-
Save marzer/c23c4f608abf7d99b1b9a921b822e025 to your computer and use it in GitHub Desktop.
Demonstrating an ICE in Visual Studio 15.5 and 15.6 pre1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code causes an internal compiler error in Visual Studio 2017. | |
//in 15.5 and 15.6 the ICE occurs in 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\parsetree.cpp' on line 1692. | |
//in the MSVC dailies (19.13.26014.0 used for this test), | |
//the ICE occurs in 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\parsetree.cpp' on line 1711. | |
#include <string> | |
#include <sstream> | |
#include <iostream> | |
#include <utility> | |
template <class CHAR> | |
using basic_string_t = std::basic_string<CHAR, std::char_traits<CHAR>, std::allocator<CHAR>>; | |
template <class CHAR> | |
using basic_ostringstream_t = std::basic_ostringstream<CHAR, std::char_traits<CHAR>, std::allocator<CHAR>>; | |
namespace Detail | |
{ | |
template<typename CHAR, typename ARG, typename... ARGS> | |
inline void Concatenate(basic_ostringstream_t<CHAR>& ss, | |
ARG&& arg, ARGS&&... args) noexcept | |
{ | |
ss << std::forward<ARG>(arg); | |
if constexpr (sizeof...(ARGS) > 0) | |
Concatenate<CHAR>(ss, std::forward<ARGS>(args)...); | |
} | |
} | |
template<typename CHAR = char, typename... ARGS> | |
basic_string_t<CHAR> Concatenate(ARGS&&... args) noexcept | |
{ | |
if constexpr (sizeof...(ARGS) == 0) | |
return {}; | |
else | |
{ | |
basic_ostringstream_t<CHAR> ss; | |
Detail::Concatenate<CHAR>(ss, std::forward<ARGS>(args)...); | |
return ss.str(); | |
} | |
} | |
int main() | |
{ | |
std::cout << Concatenate("this does not compile in ", 15.5, " or ", 15.6, " pre1!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment