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 7720791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:45:35+00:00 2026-06-01T03:45:35+00:00

Under what circumstances will _declspec( novtable ) cause an access violation? For example, this

  • 0

Under what circumstances will _declspec( novtable ) cause an access violation?

For example, this code doesn’t:

class __declspec(novtable) Base
{
public:
    virtual ~Base() { };
    virtual int Foo() const = 0;
    virtual int Bar() const { return 2; };
};

class A : public Base
{
public:
    int Foo() const { return 1; };
};

int main(int argc, char* argv[])
{
    A a;
    volatile int a1 = a.Foo();
    volatile int a2 = a.Bar();

    Base* c = new A();
    volatile int c1 = c->Foo();
    volatile int c2 = c->Bar();
    delete c;

    return 0;
}

This code also does not:

class __declspec(novtable) Base
{
public:
    virtual ~Base() { };
};

int main(int argc, char* argv[])
{ 
    Base a;
}

But, this code will:

int main(int argc, char* argv[])
{ 
    Base* a = new Base();
    delete a; // access violation
}

Why does the code in the first two example not throw on the destructors?

  • 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-01T03:45:36+00:00Added an answer on June 1, 2026 at 3:45 am

    http://msdn.microsoft.com/en-us/library/k13k85ky%28v=vs.71%29.aspx

    If you attempt to instantiate a class marked with novtable and then
    access a class member, you will receive an access violation (AV).

    The code where you get an access violation is the code where you’re explicitly calling “delete” on the novtable class.

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

Sidebar

Related Questions

Under what circumstances will the False part of the following code be executed? x
Will the Android OS kill my IntentService under normal circumstances or do I need
I am wondering under what circumstances the following NHibernate code could fail: var session
class A implements Runnable class B extends A Under these circumstances B IS A
Are there any circumstances under which a ThreadPoolExecutor.CallerRunsPolicy will throw a RejectedExecutionException ? It
Under certain circumstances, I wish to display an error message to the user if
Under what circumstances (if any) would you allow an application to change its underlying
Under what circumstances given a correct implementation of hashCode and equals() can the following
Just wondering under what circumstances would you prefer to generate a proxy from a
I am trying to figure out under what circumstances I should use weak (non-identifying)

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.