utility/value_init.hpp: VC 7.1 ICE & workaround

The SVN head of boost/utility/value_init.hpp produces a Visual C++ 7.1 ICE (see below) when compiling some of our Boost.Python extensions. The simple patch below works around the problem. I've also tested with with VC 8.0. Is this OK to commit? Thanks! Ralf P.S.: Simply inlining get() didn't work. The ICE only went away after I changed (*static_cast<T*>(ptr)).T::~T() to static_cast<T*>(ptr)->T::~T() Index: value_init.hpp =================================================================== --- value_init.hpp (revision 39257) +++ value_init.hpp (working copy) @@ -69,7 +69,11 @@ new (&x) T(); } - ~non_const_T_base() { get().T::~T(); } + ~non_const_T_base() + { + void * ptr = &x; + static_cast<T*>(ptr)->T::~T(); + } T & get() const { cl /nologo /D_SECURE_SCL=0 /D_CRT_SECURE_NO_DEPRECATE /wd4996 /Zm800 /MD /GR /EH sc /DBOOST_DISABLE_THREADS /DNDEBUG /Ox -DBOOST_ALL_NO_LIB -DBOOST_PYTHON_MAX_BA SES=2 /Iinclude /IC:\home\rwgk\hot\include /IC:\home\rwgk\dist\svnroot_cctbx\inc lude /IC:\home\rwgk\dist\svnroot_cctbx\scitbx\include /IC:\home\rwgk\dist\svnroo t_cctbx /IC:\home\rwgk\hot\boost /Ibase\python\include /IC:\home\rwgk\hot\base\p ython\include /IC:\home\rwgk\dist\svnroot_cctbx\base\python\include /c C:\home\r wgk\dist\svnroot_cctbx\scitbx\array_family\boost_python\flex_int.cpp /Foscitbx\a rray_family\boost_python\flex_int.obj flex_int.cpp C:\home\rwgk\hot\boost\boost\utility\value_init.hpp(72) : fatal error C1001: INT ERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information ____________________________________________________________________________________ Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow

Ralf W. Grosse-Kunstleve wrote:
The SVN head of boost/utility/value_init.hpp produces a Visual C++ 7.1 ICE (see below) when compiling some of our Boost.Python extensions.
Thanks for reporting the ICE caused by the MSVC workaround I committed last week! My apologizes! I didn't know about this issue. The ICE did not occur when doing the unit tests (value_init_test.cpp). Your patch:
Simply inlining get() didn't work. The ICE only went away after I changed (*static_cast<T*>(ptr)).T::~T() to static_cast<T*>(ptr)->T::~T()
Does the ICE also occur when using the destructor of the other base class, const_T_base? If so, it would need a similar patch. I will take a closer look later today, or otherwise tomorrow. And I'll contact Fernando Cacciola, the creator and maintainer of the file. Thanks again, -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center

Ralf W. Grosse-Kunstleve wrote:
The SVN head of boost/utility/value_init.hpp produces a Visual C++ 7.1 ICE (see below) when compiling some of our Boost.Python extensions.
Thanks again! I finally got a minimal example of how to reproduce the "INTERNAL COMPILER ERROR": //////////////////////////////////////////////////////////// #include <boost/utility/value_init.hpp> class Foo { }; int main() { boost::value_initialized<Foo *> i; // VC 7.1 ICE!!! return 0; } //////////////////////////////////////////////////////////// MSVC 7.1 just doesn't seem to like "get().T::~T()" when T is a pointer to an instance of a class. Apparently the bug was fixed with MSVC 8.0. BTW, MSVC 7.1 *does* accept "(&get())->T::~T()". But anyway, the patch you suggested is fine to me as well.
The simple patch below works around the problem. I've also tested with with VC 8.0. Is this OK to commit?
Please do! :-) BTW, Fernando Cacciola and I do have some ideas on how to further improve value_initialized, so I expect that your patch won't be needed anymore in the future. But at the moment, your patch is still definitely necessary! Kind regards, Niels

Ralf W. Grosse-Kunstleve wrote:
The simple patch below works around the problem. I've also tested with with VC 8.0. Is this OK to commit?
Thanks very much for your commitment! :-) FYI, I just added the same patch to the destructor of the other base class of value_initialized (const_T_base), because that one caused an ICE as well. http://svn.boost.org/trac/boost/browser/trunk/boost/utility/value_init.hpp?r... And I added a unit test for this particular issue: test<NonPOD *>( 0, &NonPOD_object ) ; http://svn.boost.org/trac/boost/browser/trunk/libs/utility/value_init_test.c... Kind regards, Niels
participants (2)
-
Niels Dekker - mail address until 2008-12-31
-
Ralf W. Grosse-Kunstleve