Beast: boost::beast::http::request causes BOOST_STATIC_ASSERT to fail

Created on 18 Oct 2018  路  8Comments  路  Source: boostorg/beast

Version of Beast: 181
compiled with Visual Studio 2015 Professional, v140

We want to use Beast for one of our projects so we updated Boost to 168 and included Beast 181. Everything is working fine except the boost::beast::http::request.

When using the boost::beast::http::request a boost_static_assert fails and prevents the program from compiling sucessfully. The assertion is located in boostintrusivedetailparent_from_member.hpp line 52.
The assertion itself:
BOOST_STATIC_ASSERT( sizeof(caster) == sizeof(int) );

We invested quite some time now but we simply can't figure out what causes the problem. This doesnt have to be an issue with boost or beast, maybe some of our project settings is causing this issue but as I already said we don't know what it is.

We have already used the boost::beast::http::request successfully in a prototype project. We were also able to reproduce the issue in the prototype. When adding the parameter "/vmg" to the project settings in Visual Studio (C/C++ - CommandLine - Additional options) a C2338 happens as well. Removing the parameter didnt fix the issue on our main project sadly.

Additional output:
\boost/intrusive/detail/parent_from_member.hpp(52): error C2338: sizeof(caster) == sizeof(int) boost/intrusive/detail/parent_from_member.hpp(98): note: see reference to function template instantiation 'ptrdiff_t boost::intrusive::detail::offset_from_pointer_to_member<boost::beast::http::basic_fields<std::allocator<char>>::value_type,Member>(const Member boost::beast::http::basic_fields<std::allocator<char>>::value_type::* )' being compiled

Most helpful comment

Pointer to member representations in MSVC is a mess. I haven't found a way to implement parent_from_member when the representation is bigger than an offset.

A way to workaround this is to use base_hooks instead of member hooks in "boost::beast::http::basic_fields".

All 8 comments

Phew...that is something! Do the tests and examples compile successfully with VS2015 v140?

@igaztanaga any ideas?

Everything compiled succesfully with VS2015 v140. I did it on my local PC and checked https://www.boost.org/development/testing.html as well

The cause is indeed /vmg flag https://godbolt.org/z/xIYba6 and it is exactly what the assert comments say.

Pointer to member representations in MSVC is a mess. I haven't found a way to implement parent_from_member when the representation is bigger than an offset.

A way to workaround this is to use base_hooks instead of member hooks in "boost::beast::http::basic_fields".

I am attempting to use the base hooks...

I changed basic_fields to use the base hooks instead, this problem should be resolved once it is merged - thanks for the report!

Thanks for the fix. We are really looking forward to use beast in our project!

We invested quite some time now

For future reference, I suggest that you (and everyone else reading this!) open an issue sooner rather than later. I know the library and boost much better than most since I wrote Beast of course, so what takes you a week might only take me a few minutes. Especially when an assert goes off, best thing to do is just open an issue right away and then continue trying to diagnose it. If I can save people hours or days of headache, it is worth it!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanVerschaeren picture JanVerschaeren  路  6Comments

MarcoRhayden picture MarcoRhayden  路  6Comments

vchang-akamai picture vchang-akamai  路  5Comments

monada99 picture monada99  路  5Comments

inetic picture inetic  路  4Comments