0

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?
Community
  • 1
  • 1
Martin Hennings
  • 16,418
  • 9
  • 48
  • 68

1 Answers1

1

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.

Pixelchemist
  • 24,090
  • 7
  • 47
  • 71
  • One can give a new warning level to a single warning via compiler flag `/wnxxxx` where n is the new level and xxxx the code of the warning. See [this answer](http://stackoverflow.com/a/4152419/399908). – Martin Hennings Jun 09 '15 at 13:15