IBM Support

IZ91500: TEMPLATE INSTANTIATION PROBLEM with sizeof

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following test case fails on AIX with xlC
    with the error:
    
    "overloadresolutionbug.cpp", line 25.45: 1540-0270 (S) An object
    of
    type "CtorLookupFailClass<int>" cannot be constructed from an
    lvalue of
    type "UniqueType * const".
    "overloadresolutionbug.cpp", line 25.3: 1540-0700 (I) The
    previous
    message was produced while processing
    "OverloadResolutionBugClass<int>::
    OverloadResolutionBugClass(UniqueType * const &)".
    "overloadresolutionbug.cpp", line 38.8: 1540-0700 (I) The
    previous
    message was produced while processing "struct C<UniqueType *
    const,
    OverloadResolutionBugClass<int> >".
    "overloadresolutionbug.cpp", line 52.5: 1540-0700 (I) The
    previous
    message was produced while processing "main()".
    
    
    
    ===== TESTCASE:
    $cat overloadresolutionbug.cpp.cpp
    
    template <typename TYPE>
    struct TypeClass {
        static TYPE& type();
    };
    
    class UninterestingType {
    };
    
    template <class T >
    class CtorLookupFailClass {
        public:
            CtorLookupFailClass();
            explicit CtorLookupFailClass(UninterestingType *);
    };
    
    template <unsigned int INT>
    struct SingleTemplateValueClass {
    enum { VALUE = (int) INT };
    };
    
    template <class T>
    class OverloadResolutionBugClass : public CtorLookupFailClass<T>
    {
    public:
      template <class U>
      OverloadResolutionBugClass (const U& v) :
    CtorLookupFailClass<T>(v) { }
    };
    
    struct UniqueType {
    } myTypeObj;
    
    struct B {
        static SingleTemplateValueClass<1> match(B&);
        template <typename T> static SingleTemplateValueClass<0>
    match(const T&);
        template <typename T> static SingleTemplateValueClass<0>
    match(const volatile T&);
    };
    
    template <typename FROM_TYPE, typename TO_TYPE >
    struct C {
    private:
      struct Test
      {
          B& operator, (TO_TYPE) const;
      };
    
    public:
      enum {
          VALUE = sizeof(B::match((TypeClass<Test>::type(),
    
    TypeClass<FROM_TYPE>::type())))
      };
    };
    
    int main () {
    
      const int a = C<struct UniqueType * const ,
    
    OverloadResolutionBugClass<int> >::VALUE;
    
      return 0;
    }
    

Local fix

  • N/A
    

Problem summary

  • PROBLEM DESCRIPTION: A template function is being instantiated
    in the operand of a sizeof, when sizeof operands are not to be
    evaluated
    
    USERS AFFECTED: the problem will only effect users who expect
    no template functions instantiated as part of the operand of a
    sizeof
    

Problem conclusion

  • template functions will no longer be instantiated when
    processing the operand of sizeof
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ91500

  • Reported component name

    XL C/C++ AIX

  • Reported component ID

    5724X1300

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2011-01-03

  • Closed date

    2011-01-03

  • Last modified date

    2011-01-05

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

    IZ80294

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

Fix information

  • Fixed component name

    XL C/C++ AIX

  • Fixed component ID

    5724X1300

Applicable component levels

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
05 January 2011