Microsoft VS2015 C++ Core Guidelines Analysis: “no array to pointer decay (bounds.3)” for vtable?












1















When I run the CppCoreCheck code analysis on my VS2015 project, I get a number of warnings which seem "unfixable" because they refer to the underlying C++ implementation of classes and vtables:



An example class:



// Header file
class IMyClass {
public:
virtual ~IMyClass() {}
virtual void MyMethod() = 0;
};

class MyClass : public virtual IMyClass {
public:
MyClass();
virtual ~MyClass();
virtual void MyMethod() override;
};


// Impl file
MyClass::MyClass() { } // This line creates two warnings from CppCoreCheck
MyClass::~MyClass() { }
void MyClass::MyMethod() { }


And the warnings:



warning C26485: Expression 'MyClass::`vbtable'': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)


The line which the warning is complaining about references the constructor definition for MyClass



For clarity; I am not directly referencing the vtable anywhere in my code; I'm simply using virtual inheritance in a 100% typical fashion.



Can someone confirm if this is a bug specific to VS2015's implementation of the CppCoreCheck? If so, is it resolved in VS2017?










share|improve this question




















  • 3





    Can you provide a small code example where this occurs ?

    – Hannes Hauptmann
    Aug 14 '18 at 13:57











  • Certainly; apologies. I've updated the question with a complete code snippet.

    – BTownTKD
    Aug 14 '18 at 14:02








  • 3





    See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

    – Richard Critten
    Aug 14 '18 at 14:06








  • 1





    Pasting your code into VS2017, I didnt get the warning message.

    – Hannes Hauptmann
    Aug 14 '18 at 14:08











  • That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

    – BTownTKD
    Aug 14 '18 at 14:26


















1















When I run the CppCoreCheck code analysis on my VS2015 project, I get a number of warnings which seem "unfixable" because they refer to the underlying C++ implementation of classes and vtables:



An example class:



// Header file
class IMyClass {
public:
virtual ~IMyClass() {}
virtual void MyMethod() = 0;
};

class MyClass : public virtual IMyClass {
public:
MyClass();
virtual ~MyClass();
virtual void MyMethod() override;
};


// Impl file
MyClass::MyClass() { } // This line creates two warnings from CppCoreCheck
MyClass::~MyClass() { }
void MyClass::MyMethod() { }


And the warnings:



warning C26485: Expression 'MyClass::`vbtable'': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)


The line which the warning is complaining about references the constructor definition for MyClass



For clarity; I am not directly referencing the vtable anywhere in my code; I'm simply using virtual inheritance in a 100% typical fashion.



Can someone confirm if this is a bug specific to VS2015's implementation of the CppCoreCheck? If so, is it resolved in VS2017?










share|improve this question




















  • 3





    Can you provide a small code example where this occurs ?

    – Hannes Hauptmann
    Aug 14 '18 at 13:57











  • Certainly; apologies. I've updated the question with a complete code snippet.

    – BTownTKD
    Aug 14 '18 at 14:02








  • 3





    See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

    – Richard Critten
    Aug 14 '18 at 14:06








  • 1





    Pasting your code into VS2017, I didnt get the warning message.

    – Hannes Hauptmann
    Aug 14 '18 at 14:08











  • That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

    – BTownTKD
    Aug 14 '18 at 14:26
















1












1








1


1






When I run the CppCoreCheck code analysis on my VS2015 project, I get a number of warnings which seem "unfixable" because they refer to the underlying C++ implementation of classes and vtables:



An example class:



// Header file
class IMyClass {
public:
virtual ~IMyClass() {}
virtual void MyMethod() = 0;
};

class MyClass : public virtual IMyClass {
public:
MyClass();
virtual ~MyClass();
virtual void MyMethod() override;
};


// Impl file
MyClass::MyClass() { } // This line creates two warnings from CppCoreCheck
MyClass::~MyClass() { }
void MyClass::MyMethod() { }


And the warnings:



warning C26485: Expression 'MyClass::`vbtable'': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)


The line which the warning is complaining about references the constructor definition for MyClass



For clarity; I am not directly referencing the vtable anywhere in my code; I'm simply using virtual inheritance in a 100% typical fashion.



Can someone confirm if this is a bug specific to VS2015's implementation of the CppCoreCheck? If so, is it resolved in VS2017?










share|improve this question
















When I run the CppCoreCheck code analysis on my VS2015 project, I get a number of warnings which seem "unfixable" because they refer to the underlying C++ implementation of classes and vtables:



An example class:



// Header file
class IMyClass {
public:
virtual ~IMyClass() {}
virtual void MyMethod() = 0;
};

class MyClass : public virtual IMyClass {
public:
MyClass();
virtual ~MyClass();
virtual void MyMethod() override;
};


// Impl file
MyClass::MyClass() { } // This line creates two warnings from CppCoreCheck
MyClass::~MyClass() { }
void MyClass::MyMethod() { }


And the warnings:



warning C26485: Expression 'MyClass::`vbtable'': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)


The line which the warning is complaining about references the constructor definition for MyClass



For clarity; I am not directly referencing the vtable anywhere in my code; I'm simply using virtual inheritance in a 100% typical fashion.



Can someone confirm if this is a bug specific to VS2015's implementation of the CppCoreCheck? If so, is it resolved in VS2017?







c++ visual-studio-2015 cpp-core-guidelines






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 17:03









versat

439




439










asked Aug 14 '18 at 13:55









BTownTKDBTownTKD

5,46922037




5,46922037








  • 3





    Can you provide a small code example where this occurs ?

    – Hannes Hauptmann
    Aug 14 '18 at 13:57











  • Certainly; apologies. I've updated the question with a complete code snippet.

    – BTownTKD
    Aug 14 '18 at 14:02








  • 3





    See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

    – Richard Critten
    Aug 14 '18 at 14:06








  • 1





    Pasting your code into VS2017, I didnt get the warning message.

    – Hannes Hauptmann
    Aug 14 '18 at 14:08











  • That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

    – BTownTKD
    Aug 14 '18 at 14:26
















  • 3





    Can you provide a small code example where this occurs ?

    – Hannes Hauptmann
    Aug 14 '18 at 13:57











  • Certainly; apologies. I've updated the question with a complete code snippet.

    – BTownTKD
    Aug 14 '18 at 14:02








  • 3





    See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

    – Richard Critten
    Aug 14 '18 at 14:06








  • 1





    Pasting your code into VS2017, I didnt get the warning message.

    – Hannes Hauptmann
    Aug 14 '18 at 14:08











  • That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

    – BTownTKD
    Aug 14 '18 at 14:26










3




3





Can you provide a small code example where this occurs ?

– Hannes Hauptmann
Aug 14 '18 at 13:57





Can you provide a small code example where this occurs ?

– Hannes Hauptmann
Aug 14 '18 at 13:57













Certainly; apologies. I've updated the question with a complete code snippet.

– BTownTKD
Aug 14 '18 at 14:02







Certainly; apologies. I've updated the question with a complete code snippet.

– BTownTKD
Aug 14 '18 at 14:02






3




3





See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

– Richard Critten
Aug 14 '18 at 14:06







See: developercommunity.visualstudio.com/content/problem/60755/… "...fixed in: visual studio 2017 version 15.5..."

– Richard Critten
Aug 14 '18 at 14:06






1




1





Pasting your code into VS2017, I didnt get the warning message.

– Hannes Hauptmann
Aug 14 '18 at 14:08





Pasting your code into VS2017, I didnt get the warning message.

– Hannes Hauptmann
Aug 14 '18 at 14:08













That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

– BTownTKD
Aug 14 '18 at 14:26







That's too bad it can't be addressed in the CppCoreChecker NuGet package. My company hasn't updated to VS2017 yet, but we'll live with the extra warnings for now. Feel free to add this as the answer.

– BTownTKD
Aug 14 '18 at 14:26














1 Answer
1






active

oldest

votes


















1














This is a known issue in VS2015 which will not be fixed. It is resolved as of VS2017, v15.5.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51843205%2fmicrosoft-vs2015-c-core-guidelines-analysis-no-array-to-pointer-decay-bound%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    This is a known issue in VS2015 which will not be fixed. It is resolved as of VS2017, v15.5.






    share|improve this answer




























      1














      This is a known issue in VS2015 which will not be fixed. It is resolved as of VS2017, v15.5.






      share|improve this answer


























        1












        1








        1







        This is a known issue in VS2015 which will not be fixed. It is resolved as of VS2017, v15.5.






        share|improve this answer













        This is a known issue in VS2015 which will not be fixed. It is resolved as of VS2017, v15.5.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 24 '18 at 14:39









        BTownTKDBTownTKD

        5,46922037




        5,46922037






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51843205%2fmicrosoft-vs2015-c-core-guidelines-analysis-no-array-to-pointer-decay-bound%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Fiat S.p.A.

            Type 'String' is not a subtype of type 'int' of 'index'