IBM Support

LI75099: -QMBCS PRODUCES WRONG BYTECODE

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The C++ compiler generates bad unicode to wide character
    literals. C compiler works.
    C++ compiler fails for all versions.
    
    In the following test case, the unicode value passed to libc
    routine wcstombs is invalid.
    If correcting the value passed to wcstombs in dbx, test case
    returns correct output and values.
    
    
    $ cat main.c
    #include <stdio.h>
    #include <stdlib.h>
    
    int main( void )
    {
     char mbsbuf[5];
     char* plocale;
     size_t nReturn;
    
     plocale = setlocale( LC_ALL, "" );
     printf( "setlocale to %s\n", plocale );
    
     nReturn = wcstombs( mbsbuf, L"?", 5 );
     printf( "After wcstombs: %s, nReturn: %d\n", mbsbuf, nReturn );
    
            return 0;
    }
    
    COMMAND LINE:
    $ /usr/vacpp/bin/xlC main.c -qmbcs -+
    $ ./a.out
    
    EXPECTED OUTPUT:
    setlocale to Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP
    After wcstombs: ?, nReturn: 1 <=HERE!!!!
    
    ACTUAL OUTPUT:
    setlocale to Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP
    After wcstombs:  , nReturn: 2  <=HERE!!!!
    
    
    A reduced test case to demonstrate the problem:
    
    <file name="test_Ja_JP.c">
    #include <stdio.h>
    #include <wchar.h>
    wchar_t  test_wch  = L'&#65521;';  // Japanese character '&#65521;' may be
    altered by CMVC
    wchar_t *test_wstr = L"&#65521;";  // Japanese character '&#65521;' may be
    altered by CMVC
    int main()
    {
        printf("%x %x\n", (unsigned int)test_wch, (unsigned
    int)test_wstr[0]);
        return 0;
    }
    </file>
    
    COMMAND LINE:
    $ xlc++ -+ -qmbcs test_Ja_JP.c
    $ ./a.out
    
    EXPECTED OUTPUT:
    ff71 ff71
    
    ACTUAL OUTPUT:
    b1 b1
    

Local fix

  • N/A
    

Problem summary

  • USER AFFECTED:
    Programs which use wide character and string literals
    encoded in Japanese locale (Ja_JP) via -qmbcs.
    
    PROBLEMDESCRIPTION:
    Under -qmbcs, the bytecode produced from wide character
    or string literals is incorrect, if the literals are
    1-byte MBCS.
    

Problem conclusion

  • Under -qmbcs, the compiler now converts wide char and string
    literals into the internal representation, using the mbtowc()
    system function, regardless whether the MBCS is 1-byte or
    multi-byte.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75099

  • Reported component name

    XL C/C++ SLES10

  • Reported component ID

    5724U8300

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-12-01

  • Closed date

    2009-12-01

  • Last modified date

    2009-12-01

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

    IZ45044

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
14 October 2021