rc-list - mailing list for the rc(1) shell
 help / Atom feed
* va_arg and short
@ 2000-12-30  3:47 Decklin Foster
  0 siblings, 0 replies; 1+ messages 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.
decklin@red-bean.com


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

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

Archives are clonable: git clone --mirror http://inbox.vuxu.org/rc-list

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.rc-list


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