Treating the abusive unsigned syndrome

Sean Kelly sean at invisibleduck.org
Tue Nov 25 13:57:41 PST 2008


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>
> At the moment, we're in limbo regarding the decision to go forward with
> this. Walter, as many good long-time C programmers, knows the abusive
> unsigned rule so well he's not hurt by it and consequently has little
> incentive to see it as a problem. I have had to teach C and C++ to young
> students coming from Java introductory courses and have a more
> up-to-date perspective on the dangers.

I'll address your actual suggestion separately, but personally, I always build
C/C++ code at the max warning level, and treat warnings as errors.  This
typically catches all signed-unsigned interactions and requires me to add
a cast for the build to succeed.  The advantage of this is that if I see a cast
in my code then I know that the statement is deliberate rather than accidental.
I would wholeheartedly support such an approach in D as well, though I can
see how this may not be terribly appealing to some experienced C/C++
programmers.


Sean



More information about the Digitalmars-d mailing list