From owner-freebsd-bugs Mon Jun 16 20:50:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id UAA20636 for bugs-outgoing; Mon, 16 Jun 1997 20:50:03 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id UAA20624; Mon, 16 Jun 1997 20:50:01 -0700 (PDT) Date: Mon, 16 Jun 1997 20:50:01 -0700 (PDT) Message-Id: <199706170350.UAA20624@hub.freebsd.org> To: freebsd-bugs Cc: From: Bruce Evans Subject: Re: bin/3884: stdarg.h fails for data types < 4 bytes Reply-To: Bruce Evans Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/3884; it has been noted by GNATS. From: Bruce Evans To: arnej@mail.math.ntnu.no, FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: bin/3884: stdarg.h fails for data types < 4 bytes Date: Tue, 17 Jun 1997 13:37:58 +1000 > The standard include file #defines va_arg to > make an explicit abort() when asked to get an argument > with sizeof(type) < sizeof(int). This is correct. The behaviour is undefined when the type in va_arg() does not match its default promotion. > Probably stdarg.h should > follow the conventions of the C compiler instead. Probably not. Generating an error is useful for detecting unportable code. However, it would be better to generate the error at compile time, and also detect float types (which happen to have the same size as their default promotion on i386's) and on char and short types (which may happen to have the same size as their default promotion on non-i386's). I don't know how to do this without using a compiler builtin. >>How-To-Repeat: > > Inspect , or compile and run the following test > program, gotten from c-torture. This program does not conform to standard C. A more amusing example is the NIST POSIX Conformance Test Suite. The entire test suite is non- conforming because a fundamental startup module uses types char, unsigned short, pid_t, clock_t, off_t and time_t in va_arg(). Typedef'ed types can never be used in va_arg(), because they may be almost anything (pid_t may be float, and time_t may be char :-). Bruce