Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOST_STATIC_ASSERT has different behavior on different platforms
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-07-27 07:38:45


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-error-c2355-this-can-only-be-referenced-inside-non-static-member-functions#

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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net