IBM Support

LI76887: ISSUES WITH BOOL VAL AND CC

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • When compiling with the cc compiler, the resulting exe produces
    an incorrect output.
    
    
    ===== COMPILE COMMAND:
    cc test.c
    
    ===== TESTCASE:
    $cat test.c
    #include <stdio.h>
    #include <stdbool.h>
    
    #ifdef THIS_WORKS
    #  define cBOOL(cbool) ((cbool) ? true : false)
    #else
    #  define cBOOL(cbool) ((bool)!!(cbool))
    #endif
    
    #define toUPPER(c) (cBOOL((c >= 'a' && c <= 'z')) ? (c - 32) :
    (c))
    
    int
    main(int argc, char **argv) {
        while (*++argv) {
            char c = **argv;
            char u = toUPPER(c);
            printf("c=%d u=%d\n", c, u);
        }
        return 0;
    }
    $
    
    
    ===== ACTUAL OUTPUT:
    $cc test.c
    $./a.out
    $ ./a.out v V
    c=118 u=86
    c=86 u=54
    $
    
    
    ===== EXPECTED OUTPUT:
    $cc test.c
    $./a.out v V
    c=118 u=86
    c=86 u=86
    $
    

Local fix

  • It will produce the expected output if you compiled the
    test case as a C++ program.
    

Problem summary

  • USERS AFFECTED:
    Users who cast a non-constant expression to _Bool may be
    affected by this issue.
    
    PROBLEM DESCRIPTION:
    Casting a non-constant expression to _Bool returns incorrect
    results.
    

Problem conclusion

  • When the expression being casted to _Bool is non-contant, the
    compiler should not just pick 0 or 1 but propagate the
    non-contant value.
    This has been corrected.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76887

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-07-16

  • Closed date

    2012-07-16

  • Last modified date

    2012-07-16

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

    IV11885

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

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI76887

Modified date: 16 July 2012


Translate this page: