IBM Support

LI75114: -QTEMPLATEREGISTRY CAUSING REPEATED COMPILES

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The issue comes from compiling a project that uses
    implicit and explicit instantiations of a template with the
    -qtemplateregistry option.  When compiled twice, the template
    registry may register an incorrect record, thus causing an extra
    recompile, or in some cases, an unending loop of compilation.
    
    =====  TEST CASE  =====
    
    The scenario is:
    file A has an implicit instantiation of foo<int>
    file B has an explicit instantiation of foo<int>
    file C has an implicit instantiation of foo<int>
    compile in the following order:
    file A
    file B
    file C
    recompile file A
    
    
    To reproduce - Build this project twice:
    
    all:
      xlC_r -qtemplateregistry -I. -c -o filea.o filea.cpp
      xlC_r -qtemplateregistry -I. -c -o fileb.o fileb.cpp
      xlC_r -qtemplateregistry -I. -c -o filec.o filec.cpp
      xlC_r -qmkshrobj -qtemplateregistry -I. -o libTest.so filea.o
        fileb.o filec.o
    
    
    --------   filea.cpp   --------
    #include "temp.h"
    
    void filea()
    {
            mytemplate<int> asdf (5);
            int temp = asdf.getfoo();
    }
    
    
    --------   fileb.cpp   --------
    #include "temp.h"
    
    template class mytemplate<int>;
    
    void fileb()
    {
            mytemplate<int> asdf (5);
    }
    
    
    --------   filec.cpp   --------
    #include "temp.h"
    
    void filec()
    {
            mytemplate<int> asdf (5);
            int temp = asdf.getfoo();
    }
    
    
    --------   temp.h      --------
    #ifndef Template_Included
    #define Template_Included
    
    template <class T>
    class mytemplate
    {
            T foo;
            public:
                    mytemplate(T arg) { foo=arg; }
                    T getfoo();
    };
    
    template <class T>
    T mytemplate<T>::getfoo()
    {
            return foo;
    }
    
    #endif
    

Local fix

  • Turn off -qtemplateregistry
    

Problem summary

  • USERS AFFECTED:
    Users who are using -qtemplateregistry and have some explicit
    instantiations in their code.  Encountering the problem will
    depend on the order of compilation.
    
    PROBLEM DESCRIPTION:
    If the user compiles an implicit instantiation before an
    explicit instantiation, the registry will record the implicit
    and explicit instantiation and the compiler will create a
    recompile record.  When the file with the implicit
    instantiation is recompiled, the compiler will try to eliminate
    the implicit one.  However it is creating a recompile record
    instead of using the explicit instantiation.  This will cause a
    source file to be recompiled that doesn't need to be.  In some
    cases this can cause an unending loop of alternating between
    recompiles of files with implicit instantiations.
    

Problem conclusion

  • The -qtemplateregistry code needs to check for explicit
    instantiations before creating a recompile record for an
    implicit instantiation that is no longer defined in the object
    file.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75114

  • Reported component name

    XL C/C++ SLES10

  • Reported component ID

    5724U8300

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-12-01

  • Closed date

    2009-12-01

  • Last modified date

    2009-12-01

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

    IZ52119

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
14 October 2021