www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/16/09:00:52

Date: Thu, 16 May 1996 15:50:17 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Rainer Wank <wank AT ftth DOT uebemc DOT siemens DOT de>
Cc: djgpp AT delorie DOT com, wank AT ftth DOT uebemc DOT siemens DOT de
Subject: Re: vararg the second
In-Reply-To: <9605100734.AA19401@malta>
Message-Id: <Pine.SUN.3.91.960516153443.5771B-100000@is>
Mime-Version: 1.0

On Fri, 10 May 1996, Rainer Wank wrote:

> 1.) You wrote, ELI ZARETSKII, that what i have done is forbidden in ANSI C.

Sorry for the long delay, been quite busy lately.

>     What parts of my code are not ANSI conform ?
>     Where can i read that the parts of the code you will mention
>     are not ANSI conform ?

The ANSI C standard says in para 7.8.1.1 ("The `va_start' macro"):

	void va_start (va_list ap, parmN);

	...

	   The parameter `parmN' is the identifier of the rightmost 
	parameter in the variable parameter list in the function 
	definition (the one just before the ", ...").  If the parameter 
	`parmN' is declared with the `register' storage class, with a 
	function or array type, or with a type that is not compatible 
	with the type that results after application of the default argument 
	promotions, the behavior is undefined.

	...

And in para 7.8.1.2 it says:

	<type> va_arg (va_list ap, <type>);

	...

	... if <type> is not compatible with the type of the actual next 
	argument (as promoted according to the default argument 
	promotions), the behavior is undefined.

P.J. Plauger in his excellent "The Standard C Library" spells this in 
plain English (p. 209):

	You must not write a type T that widens when passed as an 
	argument.  Replace `float' with `double'.  Replace `char', 
	`signed char', `unsigned char', `short' and `unsigned short' with 
	either `int' or `unsigned int'...

>     Why does the djgpp compiler does not warn me, even if have
>     used switches like -pedantic -ansi -Wall and so on ?

I don't know how easy it is for a compiler to detect such problems.  In 
any case, this should be reported to the appropriate GNU newsgroup, since 
DJGPP doesn't change the way the GNU C compiler works.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019