Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Vitaly_Trushanin
Beginner
141 Views

/EHa problem

Hi,

The following code occasionally fails with bad allocation exception or unknow exception when I compile it with /EHa flag in Release configuration. It does not fail when I build it in Debug configuration and in all configurations with MS Visual C++ Compiler. 

#include <vector>
#include <iostream>

using namespace std;

int main()
{
    try
    {
      vector<wchar_t> v;
      v.push_back( L'0' );

      cout << "Ok" << endl;
    }
    catch( std::exception& e )
    {
        cout << "Failed with " << e.what() << endl;
    }
}

I have run sample 20 times and 14 of them have fallen.

Intel(R) C++ Compiler XE, Version 12.1.3.300 Build 20120130 

OS: Windows 7 Professinal with SP1 x64

Compiler options: /c /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /Fo"Release/" /Fd"Release/vc90.pdb" /W3 /nologo /Zi

What am I doing wrong? Could you help me please?

The sample project is attached.

0 Kudos
29 Replies
SergeyKostrov
Valued Contributor II
116 Views

Here is a question: Did you try the test case with Update 7 for the Intel C++ compiler version 12? Intel(R) C++ Compiler XE, Version 12.1.7.371 Build 20120928
SergeyKostrov
Valued Contributor II
116 Views

And one more comment. I would try to change: ... vector< wchar_t > v; v.push_back( L'0' ); ... to ... vector< TCHAR > v; v.push_back( _T('0') ); ... Please let us know results of your tests.
Vitaly_Trushanin
Beginner
116 Views

I have compiled code with Intel(R) C++ Compiler XE 13.1.2.190 [IA-32] and the same results have been repeated.

I have tried to use char instead wchar_t and the same results have been repeated again. But the issue is not reproduced when I use short and int types.

SergeyKostrov
Valued Contributor II
116 Views

I confirm the problem with version 12 and the test application always throws exception: C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception C:\WuTemp>Test.exe Failed with Unknown exception The test application executed 22 times.
SergeyKostrov
Valued Contributor II
116 Views

Here is a modified test case: // icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Test.cpp #include "vector" #include "iostream" #include "tchar.h" using namespace std; int main( void ) { try { // Sub-test 1 // vector< wchar_t > v; // v.push_back( L'0' ); // Sub-test 2 // vector< TCHAR > v; // v.push_back( _T('0') ); // Sub-test 3 vector< TCHAR > v; TCHAR chV = _T('0'); v.push_back( chV ); cout << "Ok" << endl; } catch( std::exception& e ) { cout << "Failed with " << e.what() << endl; } return ( int )0; } Note: The Sub-test 3 is your workaround and it works.
SergeyKostrov
Valued Contributor II
116 Views

[ Compilation of Sub-test 2 ] C:\WuTemp>icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Test.cpp warning #13000: could not open message catalog file: diagscUI.dll Test.cpp warning #13000: could not open message catalog file: diagscUI.dll Test.cpp(20): remark #383: value copied to temporary, reference to temporary used v.push_back( _T('0') ); ^ Test.cpp(26): remark #981: operands are evaluated in unspecified order cout << "Failed with " << e.what() << endl; ^ warning #13000: could not open message catalog file: diagscUI.dll ipo: remark #11001: performing single-file optimizations ipo: remark #11006: generating object file C:\DOCUME~1\Admin\LOCALS~1\Temp\ipo_1420.obj [ Output of Sub-test 2 ] C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation C:\WuTemp>Test.exe Failed with bad allocation
SergeyKostrov
Valued Contributor II
116 Views

[ Compilation of Sub-test 3 ] C:\WuTemp>icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Test.cpp warning #13000: could not open message catalog file: diagscUI.dll Test.cpp warning #13000: could not open message catalog file: diagscUI.dll Test.cpp(31): remark #981: operands are evaluated in unspecified order cout << "Failed with " << e.what() << endl; ^ warning #13000: could not open message catalog file: diagscUI.dll ipo: remark #11001: performing single-file optimizations ipo: remark #11006: generating object file C:\DOCUME~1\Admin\LOCALS~1\Temp\ipo_1120. obj [ Output of Sub-test 3 ] C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok Note: As you can see it works when an additional variable of type TCHAR is used ( see the modified test case ).
SergeyKostrov
Valued Contributor II
116 Views

A couple of more comments: - Don't pay attention for [ warning #13000: could not open message catalog file: diagscUI.dll ] warning since this is an issue in my development environment on Windows XP - I would recommend to use Intel C++ compiler options /W5 and /check as much as possible since they help to identify lots of issues in source codes - All tests on Windows XP were done with Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.7.371 Build 20120928 - Please verify the modified test case with version 13 of Inte C++ compiler
SergeyKostrov
Valued Contributor II
116 Views

I also completed additional verification with Borland C++ compiler v5.5.1 and I confirm that there is a problem with Intel C++ compiler. Here is a modofied ( again ) test case: // bcc32.exe /O2 /D "_MBCS" Test.cpp #include "vector" #include "iostream" #include "tchar.h" using namespace std; int main( void ) { try { // Sub-test 1 // vector< wchar_t > v; // v.push_back( L'0' ); // Sub-test 2 // vector< _TCHAR > v; // v.push_back( _T('0') ); // Sub-test 3 vector< _TCHAR > v; _TCHAR chV = _T('0'); v.push_back( chV ); cout << "Ok" << endl; } catch( std::exception& e ) { cout << "Failed with " << e.what() << endl; } return ( int )0; }
SergeyKostrov
Valued Contributor II
116 Views

[ Output of Sub-test 1 with BCC v5.5.1 ] C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok [ Output of Sub-test 2 with BCC v5.5.1 ] C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok [ Output of Sub-test 3 with BCC v5.5.1 ] C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok C:\WuTemp>Test.exe Ok Note: As you can see there are No any issues, or problems, or exceptions.
Vitaly_Trushanin
Beginner
116 Views

Unfortunately workaround fails.

D:\temporary\sample\sample>icl
Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.3.300 B
uild 20120130
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

icl: command line error: no files specified; for help type "icl /help"

D:\temporary\sample\sample>icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp(19): remark #981: operands are evaluated in unspecified order
cout << "Failed with " << e.what() << endl;
^

warning #13000: could not open message catalog file: diagscUI.dll
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\VTRUSH~1\AppData\Local\Temp\
ipo_91080.obj

D:\temporary\sample\sample>Sample.exe
Failed with bad allocation

Workaround fails with both Unicode Character Set and Multi-Byte Character Set compiler options.

SergeyKostrov
Valued Contributor II
116 Views

>>Unfortunately workaround fails. >> >>D:\temporary\sample\sample>icl >>Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.3.300 Build 20120130 You need to consider installation of the most latest update for the version 12 of Intel C++ compiler.
Vitaly_Trushanin
Beginner
116 Views

Unfortunately, I don't know how to get the latest 12.x version but I've tried 13.1.2.190 version and sample fails with both Unicode Character Set and Multi-Byte Character Set compiler options.

D:\temporary\sample\sample>icl

Intel(R) C++ Compiler XE for applications running on IA-32, Version 13.1.2.190 Build 20130514
Copyright (C) 1985-2013 Intel Corporation. All rights reserved.

icl: command line error: no files specified; for help type "icl /help"

D:\temporary\sample\sample>icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Sample.cpp
Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp(19): remark #981: operands are evaluated in unspecified order
cout << "Failed with " << e.what() << endl;
^

warning #13000: could not open message catalog file: diagscUI.dll
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\VTRUSH~1\AppData\Local\Temp\
ipo_92080.obj

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>icl.exe /O2 /Oi /Qipo /D "_UNICODE" /D "UNICODE" /EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Sample.cpp
Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp(19): remark #981: operands are evaluated in unspecified order
cout << "Failed with " << e.what() << endl;
^

warning #13000: could not open message catalog file: diagscUI.dll
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\VTRUSH~1\AppData\Local\Temp\
ipo_91168.obj

D:\temporary\sample\sample>sample
Failed with Unknown exception

D:\temporary\sample\sample>sample
Failed with Unknown exception

D:\temporary\sample\sample>sample
Failed with Unknown exception

If tests with the latest 12.x version are important, could you give me a link to that build please?

SergeyKostrov
Valued Contributor II
116 Views

>>...If tests with the latest 12.x version are important, could you give me a link to that build please? You could get any updates for Intel software at: Intel Software Registration Center Web-link: registrationcenter.intel.com/regcenter/register.aspx
Vitaly_Trushanin
Beginner
116 Views

The issue is reproducible with the latest 12.x version.

D:\temporary\sample\sample>icl
Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.7.371 B
uild 20120928
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

icl: command line error: no files specified; for help type "icl /help"

D:\temporary\sample\sample>icl.exe /O2 /Oi /Qipo /D "_MBCS" /EHa /MD /GS /G
y /fp:fast /W5 /nologo /Zi Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp(19): remark #981: operands are evaluated in unspecified order
cout << "Failed with " << e.what() << endl;
^

warning #13000: could not open message catalog file: diagscUI.dll
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\VTRUSH~1\AppData\Local\Temp\
ipo_95904.obj

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>sample
Failed with bad allocation

D:\temporary\sample\sample>icl.exe /O2 /Oi /Qipo /D "_UNICODE" /D "UNICODE"
/EHa /MD /GS /Gy /fp:fast /W5 /nologo /Zi Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp
warning #13000: could not open message catalog file: diagscUI.dll
Sample.cpp(19): remark #981: operands are evaluated in unspecified order
cout << "Failed with " << e.what() << endl;
^

warning #13000: could not open message catalog file: diagscUI.dll
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\VTRUSH~1\AppData\Local\Temp\
ipo_95036.obj

D:\temporary\sample\sample>sample
Failed with Unknown exception

D:\temporary\sample\sample>sample
Failed with Unknown exception

D:\temporary\sample\sample>sample
Failed with Unknown exception

SergeyKostrov
Valued Contributor II
116 Views

>>The issue is reproducible with the latest 12.x version. >> >>D:\temporary\sample\sample>icl >>Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.7.371 Build 20120928 I see that you're compiling from the command line. My question is did you use: 'IA-32 Visual Studio 2005 mode' or 'IA-32 Visual Studio 2008 mode' or 'IA-32 Visual Studio 2010 mode' command prompt? I used 'IA-32 Visual Studio 2005 mode'. On that computer I have Windows XP 32-bit with Visual Studios 2005 Professional Edition, 2008 Express Edition and 2010 Express Edition.
Vitaly_Trushanin
Beginner
116 Views

I have used "IA-32 Visual Studio 2008 mode". On that computer I have Windows 7 64-bit with Visual Studio Team System 2008.

SergeyKostrov
Valued Contributor II
116 Views

>>I have used "IA-32 Visual Studio 2008 mode". On that computer I have Windows 7 64-bit >>with Visual Studio Team System 2008. The highest versions of VSs I have are Professional Editions. So, even if we have the same versions of Intel C++ compiler ( 12.1.7.371 ) our Visual Studios are different and, it is possible and still Not proven, that STLs are different as well. If Intel C++ compiler is integrated with Visual Studio Team System 2008 try to create a complete Visual Studio project with these simple codes ( don't forget to use the same compiler options ) and try to Debug it. That is, step into ... v.push_back( L'0' ); ... statement. Let me know if you need a help with a complete Visual Studio project.
Vitaly_Trushanin
Beginner
116 Views

The sample crashed in the following method of STL std::vector class:

template<class _Ty, class _Ax> class vector : public _Vector_val<_Ty, _Ax> {

   ...

   void _Insert_n(const_iterator _Where, size_type _Count, const _Ty& _Val) {

      ...

      pointer _Newvec = this->_Alval.allocate(_Capacity);

      ...

   }

}

Crash line screen and build log are attached.

SergeyKostrov
Valued Contributor II
44 Views

I reviewed some of my old codes and I've noticed that I never used a variable of type vector before calling a reserve( NumOfElements ) method. A modified test case is as follows: // icl.exe /O2 /EHa Test13.cpp // icl.exe /O3 /EHa Test13.cpp // bcc32.exe /O2 Test13.cpp #include "vector" #include "iostream" #undef _MBCS #define _MBCS #include "tchar.h" using namespace std; int main( void ) { try { // Sub-test 1 vector< wchar_t > v; v.reserve( 4096 ); v.push_back( L'0' ); // Sub-test 2 // vector< _TCHAR > v; // v.reserve( 4096 ); // v.push_back( _T('0') ); // Sub-test 3 // vector< _TCHAR > v; // v.reserve( 4096 ); // _TCHAR chV = _T('0'); // v.push_back( chV ); cout << "Ok" << endl; } catch( std::exception &e ) { cout << "Failed with " << e.what() << endl; } return ( int )0; }
Reply