va_list fun

Pav Lucistnik pav at FreeBSD.org
Tue Feb 15 17:16:03 PST 2005


Someone please explain to me what I'm doing wrong:

[legrace.c]
#include <stdio.h>
#include <stdarg.h>

void funny(char *format, ...) {
	va_list ap;

	va_start(ap, format);
	vfprintf(stdout, format, ap);
	vfprintf(stdout, format, ap);
	vfprintf(stdout, format, ap);
	vfprintf(stdout, format, ap);
	vfprintf(stdout, format, ap);
	va_end(ap);
}

int main(int argc, char *argv[]) {
	funny("%s\n", "string");
}


[my 4-STABLE/i386 from Dec 2 2004]
$ gcc legrace.c 
$ ./a.out 
string
string
string
string
string

[my 5-STABLE/i386 from Jan 3 2005]
$ gcc -O legrace.c 
$ ./a.out 
string
string
string
string
string

[my 5-STABLE/amd64 from Feb 10 2005]
$ gcc legrace.c
$ ./a.out
string
 çÿÿÿ

Segmentation fault (core dumped)

[sledge.freebsd.org]
$ gcc legrace.c 
$ ./a.out 
string
ðìÿÿÿ

Segmentation fault (core dumped)

[pluto2.freebsd.org]
$ gcc legrace.c 
$ ./a.out 
string
string
string
string
string


-- 
Pav Lucistnik <pav at oook.cz>
              <pav at FreeBSD.org>

94 outdated ports on the box,
94 outdated ports.
Portupgrade one, an hour 'til done,
82 outdated ports on the box.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: Toto je =?iso-8859-2?Q?digit=E1ln=EC?=
	=?ISO-8859-1?Q?_podepsan=E1?= =?iso-8859-2?Q?_=E8=E1st?=
	=?ISO-8859-1?Q?_zpr=E1vy?=
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20050216/43a9219f/attachment.bin


More information about the freebsd-amd64 mailing list