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 (JIRA)" <ji...@apache.org> on 2007/08/27 20:15:30 UTC

[jira] Assigned: (STDCXX-248) [Intel C++ 9.1/Windows] bad codegen initializing const POD struct

     [ https://issues.apache.org/jira/browse/STDCXX-248?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov reassigned STDCXX-248:
------------------------------------

    Assignee: Farid Zaripov

> [Intel C++ 9.1/Windows] bad codegen initializing const POD struct
> -----------------------------------------------------------------
>
>                 Key: STDCXX-248
>                 URL: https://issues.apache.org/jira/browse/STDCXX-248
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: External
>    Affects Versions: 4.1.3
>         Environment: Intel C++ 9.1, Windows
>            Reporter: Farid Zaripov
>            Assignee: Farid Zaripov
>            Priority: Minor
>
> 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.
-
You can reply to this email to add a comment to the issue online.