Menu

False positive: [noExplicitConstructor]

Gian Ulli
2022-09-14
2022-09-14
  • Gian Ulli

    Gian Ulli - 2022-09-14

    The following code generates a false positive [noExplicitConstructor] style warning:

    template<typename T>
    using SomeFunctionPointer = void (*)(const T *foo);
    
    template<typename T>
    class ExampleBaseClass
    {
    public:
        ExampleBaseClass(const SomeFunctionPointer<T> function, const int number)
            : m_function(function), m_number(number)
        {
        }
    
    private:
        SomeFunctionPointer<T> m_function;
        int m_number;
    };
    
    class ExampleClass : public ExampleBaseClass<int>
    {
    public:
        ExampleClass() : ExampleBaseClass(ExampleClass::exampleFunction, 42)
        {
        }
    
        static void exampleFunction(const int *foo)
        {
            (void) foo;
        }
    };
    
     
  • CHR

    CHR - 2022-09-14

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11314

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.