Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:57:06+00:00 2026-06-03T07:57:06+00:00

Is the following standard conforming? Can you cite the section? struct A { virtual

  • 0

Is the following standard conforming? Can you cite the section?

struct A
{
    virtual void func() = 0;
};

struct B
{
    void func(){}
};

struct C : public A, public B
{
    virtual void func(){ B::func(); }
};

I’m getting a strange compiler warning in VS2010 in equivalent but more complicated code pointing to func‘s declaration in the derived-most class: warning C4505: unreferenced local function has been removed. I have no idea why the compiler thinks a virtual function declared in a class is a local; however I can’t repro that warning in a simpler example.

Edit:

I figured out a small repro case for the warning. I think I was going down the wrong path assuming it was related to function hiding. Here’s the repro case:

template<typename T>
struct C
{
    int GetType() const;
    virtual int func() const;   // {return 4;}  //  Doing this inline removes the warning <--------------
};

template<typename T>
int C<T>::GetType() const
{
    return 0;
}

template<>
int C<int>::GetType() const
{
    return 12;
}

template<typename T> 
int C<T>::func() const
{
    return 3; 
}

//  Adding the following removes the warning <--------------------
//  template<>
//  int C<int>::func() const
//  {
//      return 4;
//  }

I’m fairly sure this is just a VS2010 bug.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:57:07+00:00Added an answer on June 3, 2026 at 7:57 am

    The code is well-formed. C::func overrides A::func. B::func is an unrelated function. The spec reads (10.3/2):

    If a virtual member function vf is declared in a class Base and in a class Derived, derived directly or indirectly from Base, a member function vf with the same name, parameter-type-list, cv-qualification, and ref-qualifier (or absence of same) as Base::vf is declared, then Derived::vf is also virtual (whether or not it is so declared) and it overrides111 Base::vf.

    C::func has the same name as A::func and A::func is virtual, therefore C::func overrides A::func. B::func has no relation to A::func; I don’t know that there is any language in the spec that expressly addresses that scenario.

    The Visual C++ 11 Beta compiler does not emit any warnings or errors for this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The C++ standard mandates that all conforming implementations support the following two signatures for
The C99 standard document has the following example in the section related to the
The C++0x standard working draft states (section 6.5.4) the following about the begin() and
I am using C# 3.0. Following the standard event pattern I have: public event
Following the standard instruction for using AES algorithm, I have not been able to
Consider the following 3 standard statements $queryString = SOME SQL SELECT QUERY; $queryResult =
I have the following problem that the standard library doesn't solve well, and I'm
I have the following setup: eclipse a standard Java project (A) an eclipse plugin
I have a standard ActiveRecord model with the following: class MyModel < ActiveRecord::Base custom_method
Following query is used for Getting Categories and one news for each category. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.