stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Farid Zaripov <>
Subject ICL 9.1 codegeneration bug (rw_char.h)
Date Thu, 29 Jun 2006 15:05:19 GMT
    When I compiled using Intel C++ 9.1 I've found that 
a number of rw_asserts is different than with using MSVC++ 7.1.

    I investigated this and detected the problem in UserInt::to_char() 


      UserChar UserInt::to_char () const {
          const UserChar tmp = { 0, i_ };
          return tmp;

    Assembler code, generated by ICL 9.1:

      UserChar to_char () const {
00439A44  push        ebp
00439A45  mov         ebp,esp
00439A47  push        esi
00439A48  mov         dword ptr [ebp-4],ecx
          const UserChar tmp = { 0, i_ };
00439A4B  fldz
00439A4D  mov         eax,dword ptr [ebp+8]
00439A50  fstp        qword ptr [eax]
          return tmp;
00439A52  mov         eax,dword ptr [ebp+8]
00439A55  leave
00439A56  ret         4

    As I see tmp.c is not initialized by value this->i_ and as a result 
it contains a random value.

    I tried to remove the const clause situated before UserChar, but 
nothing was changed.

      UserChar UserInt::to_char () const {
          UserChar tmp = { 0, i_ };
          return tmp;

    Then I tried the following variant and it was compiled without the bug:

      UserChar to_char () const {
          UserChar tmp;
          tmp.f = 0;
          tmp.c = static_cast<unsigned char>(i_);
          return tmp;

    I attached the test case to illustrate the problem.


View raw message