Portability and BS

Chris Torek chris at mimsy.UUCP
Tue May 17 20:43:59 AEST 1988


In article <524 at wsccs.UUCP> terry at wsccs.UUCP writes:
>Summary: Portabilty and BS

It was an apt summary:  The text (here deleted) had a little to do with
portability, and was mostly BS.  In a number of closely spaced further
postings, the same person flamed Sun's SPARC architecture and/or
compilers.  The curious thing, to me, is that while terry at wsccs
complains that SPARC makes her or his `portable' code fail, I have
never heard the same from anyone else working with a Sun-4.  But
perhaps it is just a coincidence that Terry's `portable' code fails
while everyone else's runs.

There may be (and probably are) bugs in the Sun-4 compilers that are
now available.  There are enough bugs in those supposedly stable, and
much longer tested, 4BSD and AT&T SysV compilers, that I would be very
surprised if no one ever found a bug in Sun's SPARC compilers.  The
bugs, though, are likely to be in little-used corners in the compiler:
things like `double d; ... d *= d == 3.14;'.  Terry complains about
other things: things like variable argument lists and structure
padding, things that have never been guaranteed anywhere.  Code is made
portable by virtue of not assuming those things that are not
guaranteed.  If you write code using variable argument lists and do not
stick to <varargs.h> (or, now, <stdarg.h>), your code is by definition
not portable.

In one of those other articles Terry says something that amounts to `my
code runs on many machines, therefore it is portable'.  It is not so.
An example can only disprove portability: if some code fails on a
conforming system, that code is *not* portable.  If the code runs, that
tells you only that any constraints the code may violate are not
important on that system.  It is just like saying `2 is even; 8 is
even; 6 is even; 24 is even; aha, all whole number are even.'  One
counterexample disproves it: `7 is not even: not all whole numbers are
even.'  Terry's code does not run on a Sun-4.  Unless the Sun-4 does
not conform to K&R (or perhaps the dpANS), that means Terry's code is
not portable.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list