Opened 16 years ago

Closed 16 years ago

#2324 closed defect (fixed)

Potential problems with && and || operator priority ?

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.6.0
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

GCC 4.3 emits warnings with the following tests. I was unable to determine if the current test are wrong, or if just adding parentheses as suggested would be enough. I've already added parentheses in obvious cases in r14285

gdaljp2metadata.cpp: In member function ‘int GDALJP2Metadata::ReadBoxes(FILE*)’: gdaljp2metadata.cpp:236: warning: suggest parentheses around comparison in operand of !=

            if( nMSIGSize < memcmp( pabyMSIGData, "MSIG/", 5 ) != 0 
                || nMSIGSize < 70 )
            {
                CPLFree( pabyMSIGData );
                pabyMSIGData = NULL;
                nMSIGSize = 0;
            }

geotiff.cpp: In member function ‘CPLErr GTiffDataset::OpenOffset(TIFF*, toff_t, int, GDALAccess)’:

geotiff.cpp:3318: warning: suggest parentheses around && within
/* -------------------------------------------------------------------- */
/*      Should we treat this via the RGBA interface?                    */
/* -------------------------------------------------------------------- */
    if( !bTreatAsBitmap && !(nBitsPerSample > 8) 
        && nPhotometric == PHOTOMETRIC_CIELAB ||
        nPhotometric == PHOTOMETRIC_LOGL ||
        nPhotometric == PHOTOMETRIC_LOGLUV ||
        ( nPhotometric == PHOTOMETRIC_YCBCR 
          && nCompression != COMPRESSION_JPEG ) )
    {

ogr_fromepsg.cpp: In member function ‘OGRErr OGRSpatialReference::AutoIdentifyEPSG()’:

ogr_fromepsg.cpp:1749: warning: suggest parentheses around && within
/* -------------------------------------------------------------------- */
/*      Do we have a GEOGCS node, but no authority?  If so, try         */
/*      guessing it.                                                    */
/* -------------------------------------------------------------------- */
    if( IsProjected() || IsGeographic() 
        && GetAuthorityCode( "GEOGCS" ) == NULL )
    {
        int nGCS = GetEPSGGeogCS();
        if( nGCS != -1 )
            SetAuthority( "GEOGCS", "EPSG", nGCS );
    }

Change History (2)

comment:1 by warmerdam, 16 years ago

Milestone: 1.6.0
Status: newassigned

First problem corrected in r14286, and the second in r14287.

The third fix is in my local tree, but mixed with other pending changes and hard to commit.

comment:2 by warmerdam, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed the last problem in trunk (r14303).

Note: See TracTickets for help on using tickets.