No warning on deleting a forward declared pointer (Visual Studio)

128 views Asked by At

Deleting forward declared pointers leads to undefined behavior.

Examples:

However, my Visual Studio (VS2012) compiler doesn't warn me about it.

  • Is this an unfixed VS2012 compiler bug?
  • Did I disable (or never enable) the corresponding warning?
  • Is this specific to some project setting?
  • Visual Leak Detector hinted me to the problem, but is there some method (pragma, code, macro, ...) to detect this at compile time?
1

There are 1 answers

1
Pixelchemist On BEST ANSWER

The respective warning is C4150.

It should be active by default and it is categorized in warning level 2 (which should be active too, since default warning level is W3 afaik).

Note: Instead of lowering the warning level, try to pragma warnings in specific cases.