IBM Support

LI76534: ISSUE WITH SIZEOF FOR TEMPLATES

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The test case below produces an incorrect output when
    calculating the sizeof of a struct with templates present:
    
    ===== COMPILE COMMAND:
    xlC test.cpp
    
    ===== TESTCASE:
    $cat test.cpp
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    template <int SZ> class Arr { int arr[SZ];};
    class C
    {
            public:
            struct TestIt { char Y[100]; };
      Arr <3> mem; // NOTICE THIS LINE
      enum { SizeOfTest = sizeof(TestIt) };
    
    };
    
    int main (int argc, char** argv)
    {
            C c;
      printf("%d\n",C::SizeOfTest);
    }
    $
    
    
    
    ===== ACTUAL OUTPUT:
    $xlC test.cpp
    $ ./a.out
    1
    $
    
    
    ===== EXPECTED OUTPUT:
    $xlC test.cpp
    $ ./a.out
    100
    $
    

Local fix

  • n/a
    

Problem summary

  • USERS AFFECTED:
    Users of sizeof with a member of a template class may be
    affected by this issue.
    
    PROBLEM DESCRIPTION:
    Sizeof() may not work correctly for some cases involving
    template classes.
    

Problem conclusion

  • The compiler has been fixed to resolve the sizeof() issue for
    the reported test case.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76534

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-01-09

  • Closed date

    2012-01-09

  • Last modified date

    2012-01-09

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

    IV01078

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

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI76534

Modified date: 09 January 2012


Translate this page: