From owner-freebsd-current Tue Jan 20 11:58:34 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA29972 for current-outgoing; Tue, 20 Jan 1998 11:58:34 -0800 (PST) (envelope-from owner-freebsd-current) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA29959 for ; Tue, 20 Jan 1998 11:58:25 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.8.8/8.8.5) id OAA14543; Tue, 20 Jan 1998 14:57:51 -0500 (EST) Date: Tue, 20 Jan 1998 14:57:51 -0500 (EST) From: Garrett Wollman Message-Id: <199801201957.OAA14543@khavrinen.lcs.mit.edu> To: Terry Lambert Cc: current@FreeBSD.ORG Subject: Nasty GCC bug? In-Reply-To: <199801201933.MAA27126@usr04.primenet.com> References: <199801201933.MAA27126@usr04.primenet.com> Sender: owner-freebsd-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk < said: > /* > * demonstrate bug with signed smaller-than-int arguments to > * varradic functions... > */ It's no bug, Terry... just ISO 9899:1990 in action. > What is happening is that the value is being sign-extended to int > when it is pushed on the stack. Which is precisely what is supposed to happen, since in the absence of an explicit type for that argument, the default promotions prevail, and the default promotion of `signed short' is to `signed int'. Of course, the correct type to pass for the `%x' format descriptor is `unsigned int', so you should have cast the argument explicitly. You might call it a bug in gcc that `-Wformat' does not diagnose this condition. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick