Question

Exactly what the title says. I'm using MSVC++ 2008 express, and my class constructor is never executed when compiled in release mode. It DOES work in debug mode.

I am doing something like:

ClassTest test;
test.DoIt();

Breakpoints on DoIt(); trigger, but breakpoints on ClassTest::ClassTest(); do not.

Was it helpful?

Solution

Just a thought - it could be compiler optimisation in Release mode that is preventing the breakpoint being hit. This could happen if the constructor isn't doing anything (i.e. it's a no-op). Try adding a few simple statements to the constructor, e.g.

  1. Declare a local variable
  2. Initialise the variable
  3. Use it in some way (e.g. print it out)

Then add a breakpoint on step (3) above, and see if that breakpoint is hit.

You can see all sorts of weird debugging issues with the way breakpoints are hit in Release mode, because of the optimisations which are made.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top