IBM Support

LI75101: PROTECTED MEMBER CANNOT BE ACCESSED ERROR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following legitimate C++ test case produces a compiler
    error.
    
    
    
    
    // smallest
    
    struct base{
       protected:
       void func();
    };
    
    
    struct container : base{
       using base::func;
    
       void func(){
         base::func();
       }
    };
    
    
    int main(void)
    {
       container test;
       test.func();
       return 0;
    }
    
    "nt.cpp", line 13.6: 1540-0301 (S) The "protected" member
    "base::func()" cannot be accessed.
    

Local fix

  • Use public qualifier for func.
    
    struct base{
       //protected:
       public: //workaround
       void func();
    };
    
    
    struct container : base{
       using base::func;
    
       void func(){
         base::func();
       }
    };
    

Problem summary

  • USER AFFECTED:
    Users who apply the using declaration in
    the derived class on a protected member of the base
    class.
    
    PROBLEM DESCRIPTION:
    Compiler access check does not allow a
    member in the derived class to have public access if it
    has protected access in the base class.
    

Problem conclusion

  • From C++ 2003 standard 7.3.3 (15), the
    alias created by the using declaration has the usual
    accessibility for a member declaration.  Hence, when a
    member is declared in a struct using a using
    declaration, it should have public access.  Compiler access
    check has been fixed to allow this.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75101

  • 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:

    IZ53645

  • 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