Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

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();
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top