This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Seeking patch for bug in lifetime of __cur in deque::_M_fill_initialize(powerpc dw2 EH gcc 3.4.2)
- From: Earl Chew <earl_chew at agilent dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 25 Feb 2005 11:40:54 -0800
- Subject: Seeking patch for bug in lifetime of __cur in deque::_M_fill_initialize(powerpc dw2 EH gcc 3.4.2)
[ I mailed this to the main mailing list, but in hindsight, perhaps
the libstdc++ list is a better option. ]
Is there a gcc patch for the following problem?
I am having problems with _M_fill_initialize in deque on the powerpc
version compiled at -O2.
template <typename _Tp, typename _Alloc>
void
deque<_Tp,_Alloc>::
_M_fill_initialize(const value_type& __value)
{
_Map_pointer __cur;
try
{
for (__cur = this->_M_impl._M_start._M_node;
__cur < this->_M_impl._M_finish._M_node;
++__cur)
std::uninitialized_fill(*__cur, *__cur + _S_buffer_size(),
__value);
/**** HERE ****/
std::uninitialized_fill(this->_M_impl._M_finish._M_first,
this->_M_impl._M_finish._M_cur,
__value);
/**** PATCH ****/ /* __cur++ */
}
catch(...)
{
std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur));
__throw_exception_again;
}
}
The test code is reproduced below. The assembler output of the
salient part of _M_fill_initialize is:
.L222:
lwz 3,0(31)
mr 5,30
addi 6,1,8
addi 4,3,512
.LEHB3:
bl
_ZSt24__uninitialized_fill_auxIP9TestClassS0_EvT_S2_RKT0_12__false_ty
pe
lwz 0,36(29)
addi 31,31,4
cmplw 7,0,31
bgt+ 7,.L222
li 31,0
.L240:
Examining the output .L240 corresponds to /*** HERE ***/.
When the for() loop terminates, it appears __cur is in r31 and is
zapped with 0. I suspect the optimizer has marked __cur as dead
at this point.
An exception caught whilst executing the 2nd unitialized_fill()
attempts to use __cur, but is thwarted because the value has been
lost.
I'm working with a port of dw2 based EH for powerpc VxWorks on
gcc 3.4.2. The compiler builds and is working. I have ported the EH
test from STLport, and all of the tests run.
I can work around the problem for the moment by uncommenting
the code at /* PATCH */.
Earl
-------------------------------------------------------------------------
bash-2.05b$ /gnu/local/bin/powerpc-wrs-vxworks-g++ -v -S -O2 bug.cpp
Reading specs from /gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/specs
Configured with: ../gcc-3.4.2/configure --target=powerpc-wrs-vxworks
--disable-libstdcxx-pch --disable-shared --with-included-gettext
--with-gnu-as --with-gnu-ld --with-ld=powerpc-wrs-vxworks-ld
--with-as=powerpc-wrs-vxworks-as --exec-prefix=/gnu/local
--prefix=/gnu/local --enable-languages=c,c++
Thread model: vxworks
gcc version 3.4.2
/gnu/local/libexec/gcc/powerpc-wrs-vxworks/3.4.2/cc1plus.exe -quiet -v
-DCPU_FAMILY=PPC -D__ppc -D__EABI__ -DCPU=PPC604 -D__hardfp bug.cpp
-mcpu=604 -mstrict-align -quiet -dumpbase bug.cpp -auxbase bug -O2
-version -o bug.s
ignoring nonexistent directory
"/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/../
../../../powerpc-wrs-vxworks/sys-include"
ignoring nonexistent directory "*CYGWIN1512PATH"
#include "..." search starts here:
#include <...> search starts here:
/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/../../../../include/c++/3.4.2
/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/../../../../include/c++/3.4.2/powe
rpc-wrs-vxworks
/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/../../../../include/c++/3.4.2/back
ward
/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/include
/gnu/local/lib/gcc/powerpc-wrs-vxworks/3.4.2/../../../../powerpc-wrs-vxworks/in
clude
End of search list.
GNU C++ version 3.4.2 (powerpc-wrs-vxworks)
compiled by GNU C version 3.4.1 (cygming special).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
bug.cpp:6: warning: inline function `TestClass::TestClass()' used but
never defi
ned
bug.cpp:9: warning: inline function `TestClass::~TestClass()' used but
never def
ined
bug.cpp:8: warning: inline function `TestClass::TestClass(const
TestClass&)' use
d but never defined
bug.cpp:11: warning: inline function `TestClass&
TestClass::operator=(const Test
Class&)' used but never defined
-------------------------------------------------------------------------
#include <deque>
class TestClass
{
public:
inline TestClass();
inline TestClass( int value );
inline TestClass( const TestClass& rhs );
inline ~TestClass();
inline TestClass& operator=( const TestClass& rhs );
inline int value() const;
inline TestClass operator!() const;
bool operator==( const TestClass& rhs ) const;
bool operator<( const TestClass& rhs ) const;
protected:
static inline unsigned int get_random(unsigned range = UINT_MAX);
private:
inline void Init( int value );
};
template class std::deque<TestClass>;