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 ?

Sebastian
  • 4,802
  • 23
  • 48
shijo
  • 19
  • 1
  • 1
  • 2
  • could you give real code instead of pseaudo-code? – stijn Aug 27 '10 at 07:10
  • 1
    Debugging a release build on VC++ http://msdn.microsoft.com/en-us/library/fsk896zz.aspx – DumbCoder Aug 27 '10 at 07:15
  • What does it mean when you say "this fails"? (Other than this, Kirill and I have put a lot of effort into formatting your question. Please look at what we've done and learn from it.) – sbi Aug 27 '10 at 07:31
  • related question: http://stackoverflow.com/questions/312312/what-are-some-reasons-a-release-build-would-run-differently-than-a-debug-build – sbi Aug 27 '10 at 07:38

1 Answers1

1

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

Common reasons for bugs in release version not present in debug mode

Community
  • 1
  • 1
the_mandrill
  • 29,792
  • 6
  • 64
  • 93