-
Notifications
You must be signed in to change notification settings - Fork 38
Description
We are about to use boost iostreams for the first time in our code base, and we are running into a nasty ODR problem with ni-media. The issue is that ni-media redefines BOOST_IOSTREAMS_BASIC_STREAMBUF; this causes the boost::iostreams::detail::linked_streambuf class to have a different size for compilation units that include ni-media headers vs those that don't. This is an ODR violation. When creating a Windows build with Link Time Code Generation turned on (/LTCG), this causes the following linker warning:
LINK : warning C4743: 'boost::iostreams::detail::linked_streambuf<char,struct std::char_traits<char> >::`RTTI Base Class Array'' has different size in '<one-of-our-non-ni-media-cpp-files>' and 'f:[...]\ni-media\dist\audiostream\src\ni\media\audio\ifstream.cpp': 20 and 28 bytes
We might be able to work around this by patching boost, but it would be preferable to fix it in ni-media in a way that no redefinition of BOOST_IOSTREAMS_BASIC_STREAMBUF is necessary. The reason why it is redefined is only for the friend class istream declaration, which in turn is only needed so that istream::operator>> can use protected methods such as underflow, gptr, and egptr in its implementation. This was introduced in 124bbf0; unfortunately, it's hard to tell whether that change was made to fix a defect, or to improve performance, or both.
We briefly looked into reimplementing the code without access to those protected methods, but failed because we don't understand the code well enough. For example, we didn't understand why this assertion is guaranteed to hold after a call to underflow.
@marcrambo Any thoughts?