Fixes are available
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'￱'; // Japanese character '￱' may be altered by CMVC wchar_t *test_wstr = L"￱"; // Japanese character '￱' 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
LI74729
Reported component name
XL C/C++ RHEL5
Reported component ID
5724S7310
Reported release
900
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2009-07-27
Closed date
2009-07-27
Last modified date
2009-07-27
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
XL C/C++ RHEL5
Fixed component ID
5724S7310
Applicable component levels
R900 PSN IZ51643
UP06/09/13
[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Document Information
Modified date:
16 October 2021