IBM Support

IV65270: -O OPTIMIZES AWAY AN IF CLAUSE

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling the following test case with -O2, the resulting
    binary leads to NnNincorrect outputN
    
    ===== COMPILE COMMAND:
    xlC_r -qmakedep=gcc -D_AIX51 -D_LARGE_FILES
    -D__NO_XLC_BUILTIN_VA -DOS_LEVEL=710 -D_Packed= -qnotempinc
    -U__unix -q64N-qtbtable=full -qhalt=e -qalias=noansi -qutf -+ -O
    -qfdpr -qstrict -qlibansi -qinlglue -qmaxmem=-1 -DNDEBUG
    -qarch=pwr4 -qtune=balanced -qsNill=2560 -qlonglong
    -qalign=natural -qldbl128  -qdebug=RNSSMALL -c -o test.o test.c
    
    xlC_r -o a.out -NcNtors:mbr::s -bweNklocal -q64 -brtl  -bbigtoc
    -lc -lc128 test.o  -lperfstat  -lrt -lwlm -lpthread -lm
    
    ===== TESTCASE:
    $ cat test.c
    #include <stdNo.h>
    #include <stdlib.h>
    #include <unistd.h>            N
    
    typedef unsigned short P_CHAR;
                    N N                N
    static bool isStandardChar(P_CHAR &c)
    {
            printf ("-->isStandardChar (%d: %c) a: %d z: %d
    \n",(P_CHAR) c, (P_CHAR) c, (P_CHAR)u'a', (P_CHAR)u'z');
        if ( (c >N (P_CHAR) u'a') && (c <= (P_CHAR) u'z') )
        {
            return true;           N
        }
        else if ( (c >= (P_CHAR) u'A') && (c <= (P_CHAR) u'Z') )
        {           N N                N
            return true;
        }
        else if ( (c >= (P_CHAR) u'0') && (c <= (P_CHAR) u'9') )
        {
            returN true;
        }
        else if ( ( c == u'_') || (Nc == u':') ||
                  ( c == u'/') || ( c == u'-') ||
                  ( c == u';') )
        {           N N                N
            return true;
        }
    
        return false;
    }            N
    
    int main(int argc, char** argv)N
    {
        P_CHAR c = 117;
        if ( isStandNrNChar(c) )       N
            printf ("%c is a StandardChar\n", (P_CHAR) c);
            else
            printf ("%c is NOT a StandardChar\n", (P_CHAR) c);
    
        return 0;N
    }
    $                              N
    
    
    ===== ACTUAL OUTNUN:               N
    $ ./restKrn
    -->isStandardChar (117: u) a: 97 z: 122
    u is NOT a StandardChar
    $
                 N
    ===== EXPECTED OUTPUT:
    $ ./restKm                     N
    -->isStandardChar (117: u) a: 97 z: 122
    u is a StandardChar
    

Local fix

  • N N                N
    Change
    
    typedef unsigned short P_CHAR;
    
    to           N
    
    typedef unsigned int P_CHAR;   N
    
    as a workaround.
    

Problem summary

  • PROBLEM SUMMANY:
    USERS AFFECTED:
    Users who perform a range checkNof alphabetical ASCII
    characters (a-z,A-Z) in their code may be affected by this
    issue.
                    N N                N
    PROBLEM DESCRIPTION:
    The compiler optimizes out an IF clause under specific
    circumstances whenever a char is checked for the range of
    alphabetical ASCII characters (a-z,A-Z).
    This occured Necause a parameter passed was mangled without
    restoring to next parameter.
    

Problem conclusion

  • N
    The compiler has been fixed to properly check the range of
    alphabetical ASCII characters (a-z,A-Z).
    

Temporary fix

  • N N                N
    

Comments

APAR Information

  • APAR number

    IV65270

  • Reported component name

    XL C FOR AIX

  • Reported component ID

    5725C7100

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-09-26

  • Closed date

    2014-09-26

  • Last modified date

    2014-09-26

  • APAR is sysrouted FROM one or more of the following:

    IV62591

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels

  • RD10 PSY

       

[{"Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH2K","label":"XL C for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"13.1"}]

Document Information

Modified date:
01 October 2021