IBM Support

LI77639: INCORRECT OUTPUT WITH DYNAMIC_CAST

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling the following test case that makes use of
    dynamic_cast, the compiler does not generate correct code
    leading to incorrect output at runtime.
    
    ====Compile Command:
    $ xlC -qrtti=all test.cpp
    
    
    ====Testcase:
    $ cat test.cpp
    #include <demangle.h>
    #include <stdio.h>
    int main(int argc, char *argv[])
    {
        char* rest = 0;
        char *text_mangled =
            (argc > 1) ? argv[1] : ".funcGlobalOne__Fi";
        printf("text_mangled=\"%s\"\n", text_mangled);
        Name *name = Demangle(text_mangled, rest);
        printf("name=%x\n", name);
        printf("name->Kind()=%d\n", name->Kind());
        char *text_demangled=name->Text();
        printf("text_demangled=\"%s\"\n", text_demangled);
        void *dc = dynamic_cast<void *>(name);
        printf("dynamic_cast<void *>(name)=%x\n", dc); // This
    should not be 0
        return 0;
    }
    $
    
    
    =====Actual Output:
    $ ./a.out
    text_mangled=".funcGlobalOne__Fi"
    name=201be8f8
    name->Kind()=2
    text_demangled=".funcGlobalOne(int)"
    dynamic_cast<void *>(name)=0
    $
    
    
    =====Expected Output:
    $ ./a.out
    text_mangled=".funcGlobalOne__Fi"
    name=20002a30
    name->Kind()=2
    text_demangled=".funcGlobalOne(int)"
    dynamic_cast<void *>(name)=20002a30
    $
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users of the demangler library who wish to use dynamic_cast or
    typeid on polymorphic class objects produced by the demangler
    library are affected by this issue.
    
    PROBLEM DESCRIPTION:
    RTTI information is not present for class objects produced by
    demangler library.
    

Problem conclusion

  • The version of the demangler library which is integrated with
    the C++ shared library runtime is now built with support for
    dynamic_cast and typeid.
    The stand-alone version is not updated and should not be used
    with C++ applications without careful isolation measures.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI77639

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5725C7300

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-10-28

  • Closed date

    2013-10-28

  • Last modified date

    2013-10-28

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

    IV46715

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

Fix information

  • Fixed component name

    XL C/C++ FOR LI

  • Fixed component ID

    5725C7300

Applicable component levels

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"12.1","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
14 October 2021