You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Farid Zaripov <Fa...@kyiv.vdiweb.com> on 2006/06/29 17:05:19 UTC

ICL 9.1 codegeneration bug (rw_char.h)

    When I compiled 21.string.io.cpp 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() 
method.

Incubator\stdcxx\trunk\tests\include\rw_char.h

      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.


Farid.

Re: ICL 9.1 codegeneration bug (rw_char.h)

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>    When I compiled 21.string.io.cpp 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() 
> method.
> 
[...]
>    I attached the test case to illustrate the problem.

Nicely done, thanks! Could you please open a Jira issue for this
compiler bug (see or of the other similar bugs for an example:
http://tinyurl.com/zrgcw). Once we have a bug number Anton or I
can commit your proposed fix (and reference the bug in it).

Anton, could you please file a bug with Intel for this problem
(using your Premier Support account at http://premier.intel.com)
and copy the Intel bug link into the Jira issue for reference?

Martin