Opened 18 years ago

Closed 15 years ago

#92 closed defect (fixed)

MarkupSTL.cpp - always true comparison

Reported by: mloskot Owned by:
Priority: major Milestone: 3.2.0
Component: tests Version: 2.2.2
Severity: Content Keywords: imported, phpbugtracker
Cc:

Description (last modified by mloskot)

g++ with -pedantic option reports following warning that may significantly influence logic of this code:

/home/mloskot/dev/geos/_cvs/geos/tests/xmltester/markup/MarkupSTL.cpp:884: 
 warning: comparison is always true due to limited range of data type

Here is this comparison:

int nEndCDATA = m_strDoc.find( "]]>",
                  token.nNext );
if ( (unsigned int)nEndCDATA != string::npos
&& nEndCDATA < m_aPos[iPos].nEndL )
{
   return m_strDoc.substr(token.nL+9,
          nEndCDATA-token.nL-9 );
}

Attachments (1)

MarkupSTL_cpp-ticket-92.patch (2.6 KB ) - added by mloskot 15 years ago.
Patch fixing compilation warnings thrown by GCC 4.3.x

Download all attachments as: .zip

Change History (9)

comment:2 by mloskot, 17 years ago

Description: modified (diff)
Reporter: changed from mateusz@… to mloskot

comment:3 by mloskot, 17 years ago

Milestone: imported

comment:4 by mloskot, 16 years ago

Priority: 2major
Severity: SignificantContent

comment:5 by mloskot, 16 years ago

Description: modified (diff)
Owner: strk@… removed
Status: assignednew

comment:6 by pramsey, 15 years ago

Milestone: 3.2.0

in reply to:  description comment:7 by strk, 15 years ago

warning: comparison is always true due to limited range of data type

int nEndCDATA = m_strDoc.find( "]]>",

token.nNext );

if ( (unsigned int)nEndCDATA != string::npos && nEndCDATA < m_aPos[iPos].nEndL )

Does casting to 'string::size_type' instead of 'unsigned int' fix the problem ?

by mloskot, 15 years ago

Patch fixing compilation warnings thrown by GCC 4.3.x

comment:8 by mloskot, 15 years ago

Sandro,

More or less. See MarkupSTL_cpp-ticket-92.patch for all fixes necessary to silent GCC.

comment:9 by strk, 15 years ago

Resolution: fixed
Status: newclosed

Committed, thanks.

Note: See TracTickets for help on using tickets.