Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!dino!hascall From: hascall@cs.iastate.edu (John Hascall) Newsgroups: comp.lang.c Subject: Re: common bugs in C programs Message-ID: <278@dino.cs.iastate.edu> Date: 9 Jan 90 21:57:29 GMT References: <7140.25959377@urchin.fidonet.org> <430009@hpqtdla.HP.COM> Sender: usenet@dino.cs.iastate.edu Organization: Iowa State Univ. Computation Center Lines: 20 In article <430009@hpqtdla.HP.COM> malkie@hpqtdla.HP.COM (Malcolm Rix) writes: }As we all know 'C' is a language riddled with potential problems and }pitfalls for the unwary. 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: }(14) Assuming x<<2 is the same as x*2. (Its actually x<<1). }(15) Substituting shifts for multiplies by powers of 2 in expressions } without taking taking care of change in operator precedence. also be very careful with >> as a low-budget divide }(24) Forgetting address arithmetic is done in multiples of the size of } the objects to which the pointers point. } I.e: int *a; a++; /* Points to next WORD not next BYTE */ ^^^^ may not be a WORD!! John Hascall / ISU Comp Ctr