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.
decklin@red-bean.com


^ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).