boostorg / mysql

MySQL C++ client based on Boost.Asio
https://www.boost.org/doc/libs/master/libs/mysql
Boost Software License 1.0
253 stars 32 forks source link

ODR violations when using asio::coroutine in header-only code under MSVC #259

Closed anarthal closed 4 months ago

anarthal commented 4 months ago

asio::coroutine is implemented in terms of __COUNTER__ under MSVC. If you define such coroutines in header-only code, and include the headers in several translation units, every TU will have a different definition of the function (as __COUNTER__ may have different values), effectively causing an ODR violation.

This has been a silent issue for some time already, but it's starting to manifest under some circumstances with MSVC under release builds.