beast: Boost 1.73.0/Beast 290 fails to compile with C1001 on VS 2017 Pro. with C++17 Win32 Release Config

The error/problem described in the following does only occure for C++17, Win32 Release builds with optimizations /O2 or /Ox!

While investigating a mysterious crash of our application when build and run in Win32 Release configuration we stripped down our code to only include suspicious calls to beast::http::write.

After simplifying the code it stops building with an internal compiler error C1001. (see below)

The error is located at boost/beast/http/impl/serializer.hpp line 54.

Don’t know if this helps or is important: This is the exact place (returning from serializer::do_visit) where a breakpoint (assembly int 3) gets hit and the original application crashes. Crash also only in Win32 Release /O2 and C++17.

It looks like a problem of the compiler. But we would be happy to find a work around.

Environment

Visual Studio 2017 Professional 15.9.24 on Windows 10

Version of Beast

Boost.Beast/290 Boost 1.73.0

Steps necessary to reproduce the problem

The following repository contains the completely stripped down version of our CMake/Conan settings for our project and includes a minimum working code to reproduce.

https://github.com/lenian-code/win32_cxx17_boost_beast_crash.git

The code producing the compiler error is essentially just this:

#include <iostream>
#include <boost/beast.hpp>
#include <boost/asio.hpp>

using namespace std;
int main(int argc, char *argv[])
{
	boost::asio::io_context ioc;
	boost::asio::ip::tcp::resolver resolver(ioc);
	boost::beast::tcp_stream stream(ioc);

	auto const results = resolver.resolve("localhost", "8086");

	stream.connect(results);

	boost::beast::http::request<boost::beast::http::empty_body> req(boost::beast::http::verb::head, "/ping", 11);
	req.set(boost::beast::http::field::host, "localhost");
	req.set(boost::beast::http::field::user_agent, BOOST_BEAST_VERSION_STRING);

	boost::beast::http::write(stream, req);

	boost::beast::http::response_parser<boost::beast::http::empty_body> parser;
	parser.skip(true);

	boost::beast::flat_buffer buffer;
	boost::beast::http::read(stream, buffer, parser);

	auto res = parser.release();
	if (res.result() == boost::beast::http::status::no_content) {
		cout << "no content\n";
	}

	stream.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both);
	return 0;
}

All relevant compiler information

Visual Studio 2017 Professional 15.9.24

All of the following settings are important for reproduction:

  • Win32
  • Release
  • Optimizations /O2 or /Ox
  • C++17

Build results in the following error

C1001 An internal error has occured in the compiler. File: serializer.hpp 54

1>------ Build started: Project: c1001_with_beast, Configuration: Release Win32 ------
1>main.cpp
1>c:\.conan\47aec1\1\include\boost\beast\http\impl\serializer.hpp(54): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1>

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25

Most upvoted comments

finally replicated.

It’s in one of the most complex functions we have, of course 😕