[sdiy] C coding

Rainer Buchty buchty at cs.tum.edu
Thu Feb 5 11:07:56 CET 2004


> Perfectly valid ANSI C.  A nice example of how pointer analysis is easy to
> fsck up.

Well... First of all, it is my uttermost belief that C is *no* high-level
language but a macro assembler. And just like with any other assembler
you're free to screw up the system and/or completely obfuscate your code.

Especially the latter seems to be a sports among C coders.

My favorite examples are arrays. Of course you can use them in a way that
everyone understands what's going on, i.e. using an array together with
index variables.

More likely you'll find mind-bogging pointer constructs where first a
memory area is declared, and a wandering pointer thrown in. The true
meaning of such pointer arithmetics, however, are also hard to catch for
compilers. Depending on the quality of the used compiler, they just see
the pointer, not the array behind which might be a problem if you're
heading for optimized code (compilers for the Itanium were e.g. suffering
from that some years ago, also I recall papers discussing special data
layouts in memory for most efficient cache use).

Rainer (loving the macro assembler)



More information about the Synth-diy mailing list