This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[wwwdocs] bugs.html addition
- From: Kelley Cook <kelley dot r dot cook at gm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 14 May 2002 14:15:35 -0400
- Subject: [wwwdocs] bugs.html addition
The va_args promotion seems to bite lots of legacy code (including
one of my side projects and comes up on gcc-help quite a bit.
Checked with http://validatior.w3.org
BTW, there are a lot of problems with bugs.html. The xhtml is legal
syntactically, but there are higher level semantic problems with the
proper markup meaning of <code>, <pre>, <blockquote> and others.
I'll rework it this week, if you want.
2002-05-13 Kelley Cook <kelleycook@comcast.net>
* bugs.html: Add in non-bug on proper va_arg promotions.
--- bugs.html.orig Tue May 14 13:49:30 2002
+++ bugs.html Tue May 14 13:46:52 2002
@@ -395,7 +395,19 @@
<p>In recent versions of glibc, <code>printf</code> is among the
functions which are implemented as macros.</p></dd>
-</dl>
+
+<dt><em>'short int' is promoted to 'int' when passed through '...'<br />
+(so you should pass 'int' not 'short int' to 'va_arg')</em></dt>
+<dd><p>Your code probably looks like this:</p>
+
+<blockquote><code>va_arg(list, short int);</code></blockquote>
+
+<p>This is undefined behavior according to the C standard, so
+if this worked on another compiler, you were just lucky. The
+compiler tells you how to fix your code:</p>
+
+<blockquote><code>(short int) va_arg(list, int);</code></blockquote>
+</dd></dl>
<hr />