Multi-file optimizations - bug ???

Multi-file optimizations - bug ???

Hi,

I have problem with multi-file optimizations of program that uses the standard input-output operation cin and cout and the stringstream container (see my program below). This program works well if it is compiled by Visual C++ NET or by Intel C++ 6.0 or 7.0 compiler without multi-file optimizations. But if this program is compiled by Intel C++ 6.0 or 7.0 with /Qipo options (multi-file optimizations) the I am getting run-time error.

Debugger shows that error is in ostream standard header in line 44:

explicit basic_ostream(basic_streambuf<_Elem, _Traits> *_Strbuf,
bool _Isstd = false)
{ // construct from a stream buffer pointer
_Myios::init(_Strbuf, _Isstd);
}

Could somebody tell me where is the error: in Intel compiler or in Visual Studio C++ .NET?
Any ideas anyone, as we compile programs having stringstream containers and input-output operations cin and cout with multi-file optimizations
---------------------------------------
My program:

//test-io.cpp
#include
#include "classA.h"
main()
{
using namespace std;
classA A;
cout<<"Test done"<//..
return 0;
}
///////////////////////////////
//classA.cpp
#include "classA.h"
classA::classA()
{
using namespace std;
cout<<"ClassA done"<//..
}
////////////////////////////
//classA.h
#include
#include
class classA {
public:
std::stringstream header;
classA();
};
///////////////////////

Thanks,

Jerzy

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

You may be using an older version of the compiler. I built your test case with the latest Intel compiler with package ID w_cc_p_7.1.005 (available in the File Download section of Intel Premier Support) and the test case ran without errors. I tried both command line and VS .NET IDE versions and both worked OK with the -Qipo switch.

C:ipo>icl -Qipo test-io.cpp classa.cpp
Intel C++ Compiler for 32-bit applications, Version 7.1 Build 20030307Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.

test-io.cpp
classa.cpp
IPO: using IR in test-io.obj
IPO: using IR in classa.obj
IPO: performing multi-file optimizations
Microsoft Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test-io.exe
ipo_45004.obj

C:po>test-io
ClassA done
Test done

Hi,

Thanks to msabahi.

Unfortunately, when I had added options -O1, -O2 or -O3 to options -Qipo, I got run-time error. I tried to compile this program under Visual Studio C++ .NET using Intels compilers (ver. 6.0, 7.0 and the newest 7.1 ? the latest Intel compiler with package ID w_cc_p_7.1.005).

Even simpler program having only one file and using iostream and stringstream (or fstream) generate the same problem !
For example, look at the program:

/////test-io2.cpp
#include
#include
#include

main()
{
using namespace std;
stringstream header;
fstream inoutput;
clog<<"Done"< return 0;
}
////
If I use -Qipo and -Od (no optimize) options this program works, but if I use -Qipo
and -O1, -O2 or -O3 options I get run-time error:
Unhandled exception at 0x00401af9 in test-io2.exe: 0xC0000005: Access violation reading location 0x00000004.

Debugger shows that error is in ostream standard header in line 44:
explicit basic_ostream(basic_streambuf<_Elem, _Traits> *_Strbuf,
bool _Isstd = false)
{ // construct from a stream buffer pointer
_Myios::init(_Strbuf, _Isstd);
}

The full options list showing by Visual studio is:
Compiler:

a) with /Od option (no optimize) ? program works
/c /GL /Zi /nologo /W3 /Od /Ob1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /GF /FD /EHsc /ML /GS /Gy /Fo"Release/" /Fd"Release/vc70.pdb" /Gd /TP

b) without /Od option (no optimize) but with /O1, /O2 or /O3 options (optimize) ? program does not work
/c /GL /Zi /nologo /W3 /O2 /Ob1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /GF /FD /EHsc /ML /GS /Gy /Fo"Release/" /Fd"Release/vc70.pdb" /Gd /TP

Linker:
/NOLOGO /LTCG /OUT:"Release/test-io2.exe" /INCREMENTAL:NO /DEBUG /PDB:"Release/test-io2.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /TLBID:1 /MACHINE:IX86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

The same error I am getting in program test-io2 then I remove lines:

#include
and
stringstream header;

or lines:

#include
fstream inoutput;

So, I have question:
Is it possible to use multi-file optimizations and speed optimization (-O3) of program that uses the standard input-output operation cin and cout and the stringstream container ???

Thanks,

Jerzy

hello,

during my first tests of icc i didn't get any of my program to run with /GL alias -Qipo.
due to your posts i got aware of the iostream issues (i use iostreams in basically all of my programs) and i experimented a bit with your code snipet: the problem is /EHsc. if you remove this or replace it by /EHc, the example runs. doing so you disable exception handling (or at least the synchronous exception handling, i think this concerns user generated exceptions, while system exceptions are caught?). i did not tested further, if /EHsc (or the equivalen /GX) always crashes or really only with iostreams.

markus

hello again,
i was a bit too rashly. the small example program worked with -Qipo -O3 and without /EHsc, but larger programs don't work. so there must be a problem with -Qipo and -O1/2/3 for certain programs. i can't figure out what it is.

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya