rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* va_arg and short
@ 2000-12-30  3:47 Decklin Foster
  0 siblings, 0 replies; only message in thread
From: Decklin Foster @ 2000-12-30  3:47 UTC (permalink / raw)
  To: rc

rc 1.6b2 fails to compile on linux/ppc/gcc2.95.2/glibc2.2. The problem
is in print.c line 107:

    n = va_arg(format->args, short);

This code is incorrect, because a short argument to a variadic
function will go through argument promotion and become an int. I am
told that GCC 3 will refuse to compile this on any architecture, not
just ppc.

The patch below removes the short case and adds an explanatory note.

--- print.c.orig        Fri Dec 29 22:34:45 2000
+++ print.c     Fri Dec 29 22:39:33 2000
@@ -103,9 +103,7 @@
        if (flags & FMT_long)
                n = va_arg(format->args, long);
-       else if (flags & FMT_short)
-               n = va_arg(format->args, short);
-       else
+       else /* short and int are both promoted to int */
                n = va_arg(format->args, int);
        pre = 0;

things change.

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

only message in thread, other threads:[~2000-12-30  3:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-30  3:47 va_arg and short Decklin Foster

rc-list - mailing list for the rc(1) shell

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/rc-list

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 rc-list rc-list/ https://inbox.vuxu.org/rc-list \
	public-inbox-index rc-list

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git