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

  • Home
  • SEARCH
  • 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 158373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:40:12+00:00 2026-05-11T10:40:12+00:00

I have come across what seems like a really annoying bug running my C++

  • 0

I have come across what seems like a really annoying bug running my C++ program under Microsoft Visual C++ 2003, but it could just be something I’m doing wrong so thought I’d throw it out here and see if anybody has any ideas.

I have a hierarchy of classes like this (exactly as is – e.g. there is no multiple inheritance in the real code):

class CWaitable { public:     void WakeWaiters() const     {         CDifferentClass::Get()->DoStuff(this);  // Breakpoint here     } };  class CMotion : public CWaitable {    virtual void NotUsedInThisExampleButPertinentBecauseItsVirtual() { } };  class CMotionWalk : public CMotion { ... };  void AnnoyingFunctionThatBreaks(CMotion* pMotion) {     pMotion->WakeWaiters(); } 

Okay, so I call ‘AnnoyingFunctionThatBreaks’ with a ‘CMotionWalk’ instance (e.g. the debugger says it’s 0x06716fe0), and all seems well. But when I step into it, to the breakpoint on the call to ‘DoStuff’, the ‘this’ pointer has a different value to the pMotion pointer I called the method on (e.g. now the debugger says one word higher – 0x06716fe4).

To phrase it differently: pMotion has the value 0x06716fe0, but when I call a method on it, that method sees ‘this’ as 0x06716fe4.

I’m not just going mad am I? That is weird, right?

  • 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. 2026-05-11T10:40:13+00:00Added an answer on May 11, 2026 at 10:40 am

    I believe you are simply seeing an artifact of the way that the compiler is building the vtables. I suspect that CMotion has virtual functions of it’s own, and thus you end up with offsets within the derived object to get to the base object. Thus, different pointers.

    If it’s working (i.e. if this isn’t producing crashes, and there are no pointers outside the objects) then I wouldn’t worry about it too much.

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

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Since you can guarantee they're all TestClass instances, use the… May 11, 2026 at 3:38 pm
  • added an answer This trick works for me. UIWebView *webView; int scrollPosition =… May 11, 2026 at 3:38 pm
  • added an answer Take a look at this, it's a converter from NCF… May 11, 2026 at 3:38 pm

Related Questions

In trying to learn how to create objects in ActionScript, I have had no
My math classes are far behind, and I'm currently struggling to find a decent
While considering the JS framework for my next project, I can see the scale
I have a project which I would like to make more use of smart

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.