Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jun 1997 20:50:01 -0700 (PDT)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs
Subject:   Re: bin/3884: stdarg.h fails for data types < 4 bytes
Message-ID:  <199706170350.UAA20624@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/3884; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
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 <stdarg.h> #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 <stdarg.h>, 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706170350.UAA20624>