2

I am using PC-Lint (great tool for static code analysis - see http://www.gimpel.com/) For the following chunk of code:

class ASD {
    protected:
        template<int N>
        void foo();
};

template<>
inline void ASD::foo<1>() {}

template<int N>
inline void ASD::foo() {}

PC-lint gives me a warning:

inline void ASD::foo<1>() {}
mysqldatabaseupdate.h(7) : Error 1060: protected member 'ASD::foo(void)' is not accessible to non-member non-friend functions

I believe the code is fine and the error is on the lint side, but I think Lint tool is REALLY great tool and it's more likely than I don't know something. So is this code OK?

ssobczak
  • 1,795
  • 3
  • 18
  • 28

2 Answers2

2

You have only one function foo in your struct ASD and it is in the protected section. It is not accessible from non-member functions. At the same time struct ASD doesn't have any other member functions. So nobody have access to foo, I believe this is the reason for that error message.

Try to change your struct to the following, for example:

class ASD {
    public:
        void bar() { foo<1>(); }
    protected:
        template<int N>
        void foo();
};
Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
1

The bug was in PC-Lint itself. It has been fixed in the newest version.

ssobczak
  • 1,795
  • 3
  • 18
  • 28