The following testing code does correctly in VS either with debug or release, and also in GCC. It also does correctly for ICC with debug, but not when optimization enabled (
As a slight aside, this version of icc does what you want. That is, it never calls doSomething().
doSomething()
[9:41am][wlynch@computer /tmp] icc --version icc (ICC) 11.0 20081105