rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Decklin Foster <decklin@red-bean.com>
To: rc@hawkwind.utcs.toronto.edu
Subject: va_arg and short
Date: Fri, 29 Dec 2000 22:47:05 -0500	[thread overview]
Message-ID: <20001229214705.A13372@sanpietro.red-bean.com> (raw)

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


                 reply	other threads:[~2000-12-30  3:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20001229214705.A13372@sanpietro.red-bean.com \
    --to=decklin@red-bean.com \
    --cc=rc@hawkwind.utcs.toronto.edu \
    --subject='Re: va_arg and short' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).