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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:09:03+00:00 2026-06-09T12:09:03+00:00

I am trying to figure out whether it’s safe to delete an object created

  • 0

I am trying to figure out whether it’s safe to delete an object created in module A from module B using a virtual destructor.

When using MS C++ compiler, deleting an object having a virtual destructor results in just a single vtable call and the underlying free() call is performed inside it (i.e. in the same module that created the object, i.e. safe).

The questions is: is it just the current MS implementation, or is it guaranteed in some standard or document and can be safely relied on?

Here’s the example of a disassembled virtual destructor call in VS2010:

int _tmain(int argc, _TCHAR* argv[])
{
    test *p = new test();
008A1030  push        4  
008A1032  call        dword ptr [__imp_operator new (8A20A0h)]  
008A1038  add         esp,4  
008A103B  test        eax,eax  
008A103D  je          wmain+19h (8A1049h)  
008A103F  mov         dword ptr [eax],offset test::`vftable' (8A2100h)  
008A1045  mov         ecx,eax  
008A1047  jmp         wmain+1Bh (8A104Bh)  
008A1049  xor         ecx,ecx  
    __asm int 3;
008A104B  int         3  
    delete p;
008A104C  test        ecx,ecx  
008A104E  je          wmain+28h (8A1058h)  
008A1050  mov         eax,dword ptr [ecx]  
008A1052  mov         edx,dword ptr [eax]  
008A1054  push        1  
008A1056  call        edx  
    __asm int 3;
008A1058  int         3  
    return 0;
008A1059  xor         eax,eax  
}
  • 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-09T12:09:05+00:00Added an answer on June 9, 2026 at 12:09 pm

    Well, the caller isn’t going to know the type of the object? And without knowing that type, how could the caller call Derived::operator delete ? Only Derived::~Derived can know whether Derived::operator delete must be called instead of the generic ::operator delete.

    Hence, we can deduce that the caller cannot call ::operator delete.

    It’s unspecified whether operator delete later calls free(), but that’s a detail anyway.

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

Sidebar

Related Questions

I'm using a standard SQL database and I'm trying to figure out whether or
I'm trying to figure out whether the users I get from ads will buy
I am trying to figure out from my code whether the Ring/Silent switch is
Possible Duplicate: Which JRE I am using I'm trying to figure out whether the
I'm trying to figure out whether the code located after throw new Exception in
I am trying to figure out whether or not the current date falls within
I’m trying to figure out whether FormsAuthentication.RedirectFromLoginPage (called inside method M() ), performs redirection
In the course of trying to figure out whether it's possible to contain text
I'm working on a little something and I am trying to figure out whether
In my ASP.NET MVC application, I'm trying to figure out whether the user has

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.