BOOST_STATIC_ASSERT has different behavior on different platforms

Hi,
BOOST_STATIC_ASSERT has different behavior on different platforms
Boost 1.34
-------- File foo01. cpp --------
#include

On 2010-07-27-Tue 06:32, Alexander Vinokur wrote:
BOOST_STATIC_ASSERT has different behavior on different platforms ... Foo::Foo() { BOOST_STATIC_ASSERT(sizeof(this->m_value) == 4); } ... There are compilation errors on Windows compiler
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
foo01.cpp(11) : error C2355: 'this' : can only be referenced inside non-static member functions
I think this is caused by a compiler bug, which was reported by Eric Niebler, two years ago: Microsoft Visual Studio bug report 331418, "Erroneous error C2355: 'this' : can only be referenced inside non-static member functions", http://connect.microsoft.com/VisualStudio/feedback/details/331418/erroneous-... Workaround: Foo::Foo() { Foo & self = *this; BOOST_STATIC_ASSERT(sizeof(self.m_value) == 4); } HTH, Niels -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center
participants (2)
-
Alexander Vinokur
-
Niels Dekker - address until 2010-10-10