stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-248) [Intel C++ 9.1/Windows] codegeneration bug
Date Fri, 30 Jun 2006 07:44:31 GMT
[Intel C++ 9.1/Windows] codegeneration bug
------------------------------------------

         Key: STDCXX-248
         URL: http://issues.apache.org/jira/browse/STDCXX-248
     Project: C++ Standard Library
        Type: Bug

  Components: External  
    Versions: 4.1.3    
 Environment: Intel C++ 9.1, Windows
    Reporter: Farid Zaripov


The program below is expected to run without assert. When compiled with Intel C++ 9.1 on Windows,
it's terminated with runtime error instead. Note that MSVC++ 7.1 behaves as expected. 

====================================================================== 

#include <cassert>

struct UserChar
{
    long double   f;
    unsigned char c;
};

struct UserInt
{
    int   i_;

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

    UserChar to_char2 () const
    {
        UserChar tmp = { 0, i_ };
        return tmp;
    }

    UserChar to_char3 () const
    {
        UserChar tmp = { 0 };
        tmp.c = i_;
        return tmp;
    }
};

int main(int argc, char* argv[])
{
    const char TEST_CHAR = 'a';

    UserInt ui = { TEST_CHAR };

    UserChar uc = ui.to_char ();
    UserChar uc2 = ui.to_char2 ();
    UserChar uc3 = ui.to_char3 ();

    assert (TEST_CHAR == uc.c && TEST_CHAR == uc2.c && TEST_CHAR == uc3.c);

    return 0; 
}

====================================================================== 

icl icl91_test.cpp
Intel(R) C++ Compiler for 32-bit applications, Version 9.1    Build 20060323Z
Copyright (C) 1985-2006 Intel Corporation.  All rights reserved.

icl91_test.cpp
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:icl91_test.exe
icl91_test.obj

====================================================================== 

icl91_test.exe
Assertion failed: TEST_CHAR == uc.c && TEST_CHAR == uc2.c && TEST_CHAR ==
uc3.c,
 file icl91_test.cpp, line 43

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

====================================================================== 

Generated assembler code:

      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

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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message