common bugs in C programs
Scott Amspoker
scott at bbxsda.UUCP
Tue Jan 9 09:02:10 AEST 1990
In article <430009 at hpqtdla.HP.COM> malkie at hpqtdla.HP.COM (Malcolm Rix) writes:
> While developing code and reviewing the work of others
>in the common firmware group we have been collecting a list of the most
>frequent problems:
>[list deleted]
one of my favorites:
i = (getchar()<<8) + getchar();
The evaluation order is not guaranteed. A similar thing can happen
with function arguments.
should be: i = getchar()<<8;
i += getchar();
--
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232
unmvax.cs.unm.edu!bbx!bbxsda!scott
More information about the Comp.lang.c
mailing list