@mattmoss said:
Found a whole bunch of WTFs in a project from a previous lead programmer, but this one (C++) stumped me for a while:
CSound* sound = sound->SetVolume(v);
...
Now, I don't know the C++ Standard quite that well to know if this is valid or not. Even if it was, it's most definitely a WTF for me...
It is definitely not valid, even though the code is invoking a static method. This falls into the realm of what the C++ standard defines as "undefined behavior". Thus, the previous code might do what the author expected, might crash, or it could launch a nuclear missle strike - one can't tell.
Of course, pretty much any C++ implementation will just call the static method without dereferencing 'sound', and the code will work as expected. But it doesn't have to.
-matt