IBM Support

IV16478: 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

    IV16478

  • Reported component name

    XL C AIX

  • Reported component ID

    5724S7000

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-02-29

  • Closed date

    2012-02-29

  • Last modified date

    2012-04-24

  • 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 AIX

  • Fixed component ID

    5724S7000

Applicable component levels

  • R900 PSN U850264

       UP06/09/13 C

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
24 April 2012