Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Condition badly evaluated (compiler bug?)

atraversi
Beginner
252 Views

Hi, my english is bad!

I am migrating from Intel v9.0/VS2003 to Intel v9.1.037/VS2005 SP1 and Boost v1.3.4

Its a Debug compilation, optimizations are disabled.

I have problems with the implicit bool operator of the boost::shared_ptr class.

Look at the highLighted line:

void * HDEOutlined::Streamer::Read ( ipstream & in , uint32 aVersion ) const

{

HDEOutlined* lThis = GetObject() ;

if ( in )

{

shared_ptr lSplitlineList ;

// Current Version: 4

if ( aVersion > 1 ) // 2->4

{

if ( aVersion < 3 ) // 2

lSplitlineList = readList_noFlag(in);

else

{

shared_ptr< HFCurveNodesList> lCNSplitlineList ;

if ( aVersion < 4 ) // 3

lCNSplitlineList = readList_noFlag(in) ;

else // 4

lCNSplitlineList = readList(in);

if( lCNSplitlineList )

{

lSplitline2List.reset( new HFInterpolatedCurveList() ) ;

copy(lCNSplitlineList->begin(),lCNSplitlineList->end(),back_inserter(*lSplitline2List));

}

}

}

if ( lSplitlineList )

{

lSplitline2List.reset( ConvertOldSplitlineList (*lSplitlineList) );

}

lThis -> mSplitlineList = lSplitline2List ;

}

return lThis ;

}

The highlighted if condition is not evaluated properly.

The shared_ptr operator bool is never called.

The execution evaluate the 'if' as TRUE,when lSplitlineList is a pointer to NULL. The 'if' clearly is FALSE!

The aVersion argument value is 4.

HDotLineList is declared as:

typedef std::vector< shared_ptr > HDotLineList ;

Look at the dissasembly:

if ( lSplitlineList )

090EB4D5 mov eax,dword ptr [ebp-68h]

090EB4D8 mov edx,dword ptr ds:[91E006Ch]

090EB4DE cmp eax,edx

090EB4E0 jne 090EB510 ; Here jumps

090EB4E2 lea eax,[ebp-6Ch]

090EB4E5 push edi

090EB4E6 mov dword ptr [esp],eax

090EB4E9 lea eax,[lSplitlineList]

090EB4EF mov ecx,eax

090EB4F1 call shared_ptr::operator boost::shared_ptr::unspecified_bool_type (8F681A8h) ; This line is never reached

090EB4F6 mov eax,dword ptr [ebp-64h]

090EB4F9 mov edx,dword ptr ds:[91E0070h]

090EB4FF cmp eax,edx

090EB501 jne 090EB510

090EB503 mov eax,dword ptr [ebp-6Ch]

090EB506 mov edx,dword ptr ds:[91E0068h]

090EB50C cmp eax,edx

090EB50E je 090EB544

{

lSplitline2List.reset ( ConvertOldSplitlineList ( *lSplitlineList ) ) ;

090EB510 lea eax,[lSplitlineList]

090EB516 mov ecx,eax

090EB518 call shared_ptr::operator* (8F67F2Ch)

090EB51D mov dword ptr [ebp-4Ch],eax

090EB520 push edi

090EB521 mov eax,dword ptr [ebp-4Ch]

090EB524 mov dword ptr [esp],eax

090EB527 call ConvertOldSplitlineList (90F9268h)

Compiled with Intel v9.0/VS2003 this works fine.

Is this a compiler error?

Help me, how can i solve the problem?

Angel Traversi

0 Kudos
3 Replies
JenniferJ
Moderator
252 Views
did you update the boost lib when switching to 9.1? Or maybe you need to add a predefined macro in the compile option?
0 Kudos
atraversi
Beginner
252 Views

Thanks jljiang

I update boost lib from 1.33 to 1.34 (the last release)

0 Kudos
levicki
Valued Contributor I
252 Views

Does adding volatile keyword in front of lSplitlineList variable declaration fix your problem?

0 Kudos
Reply