views:

85

answers:

1

I am facing a problem in release build of Visual Studio

pseudo code is given below

#include "lib/A/inc/A.h"

main()
{
  A a;
  a.f1();//this fails in release build and works fine in debug build
  a.f2();//this fails in release build and works fine in debug build
}

A is derived from B present in lib/B/inc/B.h

class A :public B
{
  virtual f2();
};

B has a pure virtual function f2() and normal f1()

class B {
private:
  string name;
public:
  void f1();
  virtual void f2() = 0;
};

I stepped in to the f1() function. At this moment this pointer of B has value 0x0000000 and __vfptr is invalid.

But in main() , object a is valid and __vfptr is also valid. Any idea why this happend in release build ?

A: 

Have a look through some of the differences between a debug and release build and my tips for finding the bug:

http://stackoverflow.com/questions/1762088/common-reasons-for-bugs-in-release-version-not-present-in-debug-mode/2810992#2810992

the_mandrill