APAR status
Closed as program error.
Error description
With the legacy V16.1 xlC, the test case compiles and runs fine with -qlanglvl=scopedenum But when compiled with the new xlclang++, the resulting exe aborts. ===== COMPILE COMMAND: xlclang++ -g -std=c++14 test.cpp ===== TESTCASE: $ cat test.cpp #include <cstdio> #include <cassert> #if !defined(__clang__) #include <uchar.h> #endif enum SC_TOK_ROLE : char16_t { ROLE_NO_SET = ('\1'), ROLE_NONE = ('a'), ROLE_WORD = ('b'), ROLE_KEYWORD = ('c'), ROLE_TYPE = ('d'), ROLE_VALUE = ('3'), }; static struct { char name[30]; SC_TOK_ROLE role; } sypatttab[] = { { "word", ROLE_WORD }, { "val", ROLE_VALUE }, }; int main() { printf("%.30s -> role(%d)\n", sypatttab[0].name, sypatttab[0].role); printf("%.30s -> role(%d)\n", sypatttab[1].name, sypatttab[1].role); assert(sypatttab[0].role == ROLE_WORD); assert(sypatttab[1].role == ROLE_VALUE); return 0; } $ ===== WORKAROUND: when you move the main statement above the static struct AND remove the static-keyword, then it works fine. It works also if you just change the data type of the enum from char16_t into int16_t. ===== ACTUAL OUTPUT: $ xlclang++ -g -std=c++14 test.cpp $ ./a.out word -> role(4797) val -> role(4797) Assertion failed: sypatttab[0].role == ROLE_WORD, file test.cpp, line 32 Abort $ ===== EXPECTED OUTPUT: Same as the output with legacy xlC: $ xlC -g -qlanglvl=scopedenum test.cpp $ ./a.out word -> role(98) val -> role(51) $
Local fix
The workaround is to move the main statement above the static struct AND remove the static-keyword. Another workouarnd is if you just change the data type of the enum from char16_t into int16_t.
Problem summary
USERS AFFECTED: Users of C++11 scoped enum of char16_t type may be affected by this issue. PROBLEM DESCRIPTION: Serialization fails to map the underlying enum type to one of the types it knows how to serialize resulting in invalid codegen.
Problem conclusion
The fix is to correctly lower the underlying type of scope enums.
Temporary fix
Comments
APAR Information
APAR number
IJ24631
Reported component name
XL C/C++ FOR AI
Reported component ID
5725C7200
Reported release
G10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2020-04-30
Closed date
2020-04-30
Last modified date
2020-04-30
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++ FOR AI
Fixed component ID
5725C7200
Applicable component levels
[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Line of Business":{"code":"LOB73","label":"Power TPS"}}]
Document Information
Modified date:
22 August 2024