[C++-sig] weird bug of addressof<T> in MSVC 7

Nicolas Lelong n_lelong at hotmail.com
Tue Jan 7 10:29:28 CET 2003


Hi,

I stumbled upon a weird compilation error due to function 'addressof' in
MSVC7. Here is my test case :

************

class Test
{
public:

  struct Parameters
  {
  };

};

BOOST_PYTHON_MODULE( test )
{
  python::class_<Test::Parameters> Parameters_class("Parameters");    /*
this line causes the compile bug */
};

************

Here is what the compiler tells me :

************

d:\Sources\mgd\include\boost\utility\addressof.hpp(28) : error C2440:
'return' : cannot convert from 'const Test::Parameters *' to
'Test::Parameters *'

Conversion loses qualifiers

d:\Sources\mgd\include\boost\ref.hpp(40) : see reference to function
template instantiation 'Test::Parameters *boost::addressof(const T &)' being
compiled

with

[

T=Test::Parameters

]

d:\Sources\mgd\include\boost\ref.hpp(40) : while compiling class-template
member function 'boost::reference_wrapper<T>::reference_wrapper(const
Test::Parameters &)'

with

[

T=const Test::Parameters

]

d:\Sources\mgd\include\boost\python\object\make_instance.hpp(64) : see
reference to class template instantiation 'boost::reference_wrapper<T>'
being compiled

with

[

T=const Test::Parameters

]

d:\Sources\mgd\include\boost\python\object\class_wrapper.hpp(27) : see
reference to class template instantiation
'boost::python::objects::make_instance<T,Holder>' being compiled

with

[

T=Test::Parameters,

Holder=holder

]

d:\Sources\mgd\include\boost\python\object\class_wrapper.hpp(26) : while
compiling class-template member function 'PyObject
*boost::python::objects::class_cref_wrapper<Src,MakeInstance>::convert(const
Src &)'

with

[

Src=Test::Parameters,

MakeInstance=boost::python::objects::make_instance<Test::Parameters,holder>

]

d:\Sources\mgd\include\boost\python\class.hpp(88) : see reference to class
template instantiation
'boost::python::objects::class_cref_wrapper<Src,MakeInstance>' being
compiled

with

[

Src=Test::Parameters,

MakeInstance=boost::python::objects::make_instance<Test::Parameters,holder>

]

d:\Sources\mgd\include\boost\python\class.hpp(479) : see reference to
function template instantiation 'void
boost::python::detail::register_copy_constructor(const boost::mpl::bool_c<C>
&,const boost::python::objects::detail::select_value_holder<T,Held>
&,Test::Parameters *)' being compiled

with

[

C=true,

T=Test::Parameters,

Held=Test::Parameters

]

c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xlocnum(80) :
while compiling class-template member function 'void
boost::python::class_<T,X1,X2,X3>::register_(void) const'

with

[

T=Test::Parameters,

X1=boost::python::detail::not_specified,

X2=boost::python::detail::not_specified,

X3=boost::python::detail::not_specified

]

c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xmemory(136) :
while compiling class-template member function
'boost::python::class_<T,X1,X2,X3>::class_(const char *,const char *)'

with

[

T=Test::Parameters,

X1=boost::python::detail::not_specified,

X2=boost::python::detail::not_specified,

X3=boost::python::detail::not_specified

]

d:\Sources\mgd\Tests\Python\Python.cpp(232) : see reference to class
template instantiation 'boost::python::class_<T,X1,X2,X3>' being compiled

with

[

T=Test::Parameters,

X1=boost::python::detail::not_specified,

X2=boost::python::detail::not_specified,

X3=boost::python::detail::not_specified

]

************

What is quite weird is that I added a '#pragma message (__FUNCSIG__)' in
'addressof'
code ; and the faulty compiled function has the follwing signature:

    struct Test::Parameters *__cdecl boost::addressof(const struct
Test::Parameters &)

It seems to me that this signature should be :

    const struct Test::Parameters *__cdecl boost::addressof(const struct
Test::Parameters &)

It looks like a compiler bug to me. This only seems to happen for classes of
structs contained
in another class (or struct).

I'm no expert in compiler bug workaround so I could not find anything
interesting - but maybe
am I just missing something ?!

Any thoughts ?

Thanks,
Nicolas.




More information about the Cplusplus-sig mailing list