Why isn't argv[argc]==(char *)0 ?

Mark J Elkins mje at olsa99.UUCP
Fri Dec 15 03:20:30 AEST 1989


In article <2673 at auspex.auspex.com>, guy at auspex.auspex.com (Guy Harris) writes:
Guy >>>(I.e., unless you have to deal with an archaic UNIX or a Mutant UNIX
Guy >>>From Hell, you can count on argv[argc] == 0.)

In article <1635 at ctisbv.cti-software.nl> Pim Zandgerger wrote...
Pim >>In X/OS, a SYSV/BSD hybrid operating system for the Olivetti LSX
Pim >>minicomputers, a reference to argv[argc] will make your program dump core.

> If you mean "a *de*reference *of* 'argv[argc]' will make your program
> dump core", that's true on Suns as well, and some other machines, since
> they don't let you dereference null pointers.
> 
> If you mean "even trying to copy the (pointer) *value* somewhere else
> causes a core dump", then I think the label "Mutant UNIX From Hell" is
> well-deserved; I've nothing against, say, array bounds-checking, but
> "argv" has "argc+1" elements, not "argc" elements - if Olivetti intends
> to get POSIX or ANSI C support on the LSX, they'd better fix this....

Mark Elkins writes....

OK Guys - I am the support person for Olivetti Africa and was a little
upset about the accusation. I ran the following program... (Called 'e.c')


main(ac,av)
int ac;
char *av[];
{
char *cp;

printf("Value of av[ac] = %s\n",av[ac]);
cp = av[ac]; printf("Value of cp = %s\n",cp);
while (ac >= 0) printf("Arg %d = %s\n",ac--,*av++);
}

and it produced.....


Value of av[ac] = (null)
Value of cp = (null)
Arg 4 = e
Arg 3 = one
Arg 2 = two
Arg 1 = three
Arg 0 = (null)

The Machine is a LSX 3020 Machine (68020 @ 17 Meg) running X/OS Rel 2.1
(Olivetti's Unix - Bastardisation of Sys V Rel 3.0 and BSD 4.2 - peppered
with Olivetti features)

Go suck eggs  (or maybe upgrade your system)

(Any replies - please mail mje at olsa99 - my news feed is down)
-- 
  .  .     ___. .__       Olivetti Africa, Unix 'Everything-except-sales'
 /| /|       / /__        UUCP: uunet!olsa99!mje (Mark J Elkins)
/ |/ |ARK \_/ /__ LKINS   mje at olsa99.UUCP   - Living in GMT-2



More information about the Comp.unix.wizards mailing list