const assignments problem again

Kagamin spam at here.lot
Sun Aug 7 03:02:36 PDT 2011


Jonathan M Davis Wrote:

> Being able to use const can be very valuable. For instance, what if you were 
> using std.algorithm.copy and got the arguments backwards? If the source is 
> const, then the compiler will complain, and you'll quickly find the bug. If the 
> source isn't const, then you could accidentally end up copying the target to 
> the source, and it may or may not be an easy bug to catch.

I've seen a bug. I fixed two methods: begin and end and sent the patch to a man. They were calling other methods (sort of begin1 and end1). The man slightly fixed my patch and copied the fixed body of the first method to both of them (they look very similar). The compiler was happy, the application even worked. The bug was catched only because I checked whether the man did it right.


More information about the Digitalmars-d mailing list