tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: stdargs.h bug? V4.0F, PK#3
@ 2000-10-30 21:33 Narendra Ra[a]vi
  0 siblings, 0 replies; only message in thread
From: Narendra Ra[a]vi @ 2000-10-30 21:33 UTC (permalink / raw)
  To: tru64-unix-managers



Thanks to

Dan Riley
Serguei Patchkovskii

I was not ending the argument list. Changing

         execit("test", "one", "two", "three");

to 

         execit("test", "one", "two", "three", (char *) 0);

worked fine. Gotta relearn how to read the man pages.


-- 

 -- Narendra Ravi     Email : narendra@spiff.hr.att.com
    MT  A4-4B27       Phone : 732-420-7792

ORIGINAL MESSAGE:
> 
> Hi Managers,
> 
> Have any of you got complaints that the C library implementation of
> stdarg.h?  Is there a patch for this problem in the Standard C library?
> 
> I have the following program (straight from the man page for stdarg) that
> dumps core at the fourth argument.
> 
> #include <stdarg.h>
> #include <iostream.h>
> 
> #define MAXargS 100
> /*
> **  execl is called by
> **  execl(file, arg1, arg2, . . . , (char *) 0);
> */
> void
> execit(char * file, ...)
> {  va_list ap;
>   char *args[MAXargS];
>   int argno = 0;
>   va_start(ap, file);
>   for (; (args[argno] = va_arg(ap, char *)) != (char *) 0; argno++)
>   {
>               // prints an invalid fourth address.
>         cout << "addr: " << hex << (void*) args[argno] << endl;
>               // dumps core when printing the fourth argument. Obviously.
>         cout << "arg : " << args[argno] << endl;
>   }
>   va_end(ap);
>   //return (execv(file, args));
> }
> 
> int
> main()
> {
>         execit("test", "one", "two", "three");
> }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-10-30 21:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-30 21:33 SUMMARY: stdargs.h bug? V4.0F, PK#3 Narendra Ra[a]vi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox