Cleaned up C++

ponce via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 22 12:51:22 PDT 2015


On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote:
> I'd missed this post on reddit:
>
> http://www.reddit.com/r/programming/comments/30wj8g/managing_cs_complexity_or_learning_to_enjoy_c/cpx41ix

Thanks for the mention. I must have forgotten some. I should put 
in in a d-idioms anyway.

I didn't appreciate how important default initialization was 
before having to fix a non-deterministic, release-only, 
time-dependent bug in a video encoder some months ago. Just 
because of 2 uninitialized variables (C++ doesn't require member 
initialization in constructor). If one of them was _exactly equal 
to 1_ by virtue of randomness, then it would perform from 0 to 2 
billions of motion estimation steps, which is very slow but not a 
total halt. A watchdog mechanism would detect this and reboot, 
hence labelling the bug "a deadlock". It would disappear in debug 
mode since variables would be initialized then.

That gives a totally other meaning to "zero cost abstractions" 
since in three weeks of investigation I could have speed-up the 
program by ~5%, much more than the supposed slowdown of variable 
initialization.




More information about the Digitalmars-d mailing list