ctype constructor - wrong code generated

M R Swami Reddy MR.Swami.Reddy@nsc.com
Mon May 11 09:32:00 GMT 2009


Hello All,
Am using a cross compiler with libstdc++ support.
With -O1 and above optimization, wrong instruction generated, which
cause the stack corrupted. Appropriate your advise/suggestion.
[with -O0 correct code generated].
sample code is:
===
#include <locale>

namespace std
{
   ....
   ctype<wchar_t>::ctype(size_t __refs)
   : __ctype_abstract_base<wchar_t>(__refs)
   { _M_initialize_ctype();  }
...

} // namespace std
=====
Compiler generated code (note: argument-1 passed using "r3,r2" register pair, 
which is corrupt using "stord  sp, 32(sp) instead of stord (r3,r2), 32(sp)).
===============
        .type   __ZNSt5ctypeIwEC1Em, @function
__ZNSt5ctypeIwEC1Em:
         push    $2, r13, ra
         push    $7, r7
         addd    $-44, (sp)
         stord   (r5,r4), 36(sp)
         ....
         stord   (r1,r0), 20(sp)
         stord   (sp), 24(sp)
         movd    $.L13, (r1,r0)
         stord   (r1,r0), 28(sp)
         stord   (sp), 32(sp)   /* WRONG: instead of (r3,r2) its storing sp */
         movd    (sp), (r3,r2)
         ......
         loadd   32(sp), (r3,r2) /*use here */
         stord   (r1,r0), 4(r3,r2)
         ....
===========




More information about the Gcc-help mailing list