From eserte@cottrell.dialup.fu-berlin.de  Sun Oct 12 16:41:47 1997
Received: from cottrell.dialup.fu-berlin.de (anonymous220.ppp.cs.tu-berlin.de [130.149.17.220])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA28358
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 Oct 1997 16:41:40 -0700 (PDT)
          (envelope-from eserte@cottrell.dialup.fu-berlin.de)
Received: (from eserte@localhost)
	by cottrell.dialup.fu-berlin.de (8.8.5/8.8.5) id BAA00623;
	Mon, 13 Oct 1997 01:39:05 +0200 (CEST)
Message-Id: <199710122339.BAA00623@cottrell.dialup.fu-berlin.de>
Date: Mon, 13 Oct 1997 01:39:05 +0200 (CEST)
From: Slaven Rezic <eserte@cs.tu-berlin.de>
Reply-To: eserte@cs.tu-berlin.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: cc -Wformat too sensitive
X-Send-Pr-Version: 3.2

>Number:         4748
>Category:       gnu
>Synopsis:       cc -Wformat too sensitive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 12 16:50:01 PDT 1997
>Closed-Date:    Mon Mar 29 18:00:17 PST 1999
>Last-Modified:  Mon Mar 29 18:00:38 PST 1999
>Originator:     Slaven Rezic
>Release:        FreeBSD 2.2.1-RELEASE i386
>Organization:
Private FreeBSD site, Berlin, Germany
>Environment:

>Description:

	cc -Wformat warns about "flag `0' used with type `s'". But due
	to the manpage, this is correct and produces the expected
	code, too.

>How-To-Repeat:

	Try this code with "cc -Wformat foo.c":

	#include <stdio.h>
	main() {
	  printf("%08s\n", "12");
	}


>Fix:
	
	The following patch should fix the problem (not tested). Patch
	against file in /usr/src/contrib/gcc.

--- c-common.c.orig	Mon Oct 13 01:33:18 1997
+++ c-common.c	Mon Oct 13 01:34:06 1997
@@ -705,7 +705,7 @@
   { "feEgG",	0,	T_D,	NULL,	NULL,	NULL,	T_LD,	"-wp0 +#"	},
   { "c",	0,	T_I,	NULL,	T_W,	NULL,	NULL,	"-w"		},
   { "C",	0,	T_W,	NULL,	NULL,	NULL,	NULL,	"-w"		},
-  { "s",	1,	T_C,	NULL,	T_W,	NULL,	NULL,	"-wp"		},
+  { "s",	1,	T_C,	NULL,	T_W,	NULL,	NULL,	"-wp0"		},
   { "S",	1,	T_W,	NULL,	NULL,	NULL,	NULL,	"-wp"		},
   { "p",	1,	T_V,	NULL,	NULL,	NULL,	NULL,	"-w"		},
   { "n",	1,	T_I,	T_S,	T_L,	T_LL,	NULL,	""		},

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: eserte@cs.tu-berlin.de, FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: Re: gnu/4748: cc -Wformat too sensitive
Date: Mon, 13 Oct 1997 11:40:27 +1000

 >>Description:
 >
 >	cc -Wformat warns about "flag `0' used with type `s'". But due
 >	to the manpage, this is correct and produces the expected
 >	code, too.
 >...
 >	  printf("%08s\n", "12");
 
 Doing something reasonable for this is a BSD extension.  It gives
 undefined behaviour in Standard C, so warning about it is correct.
 The FSF version of gcc has to warn about it because it cannot know
 about extensions in vendor libraries.
 
 BTW, we should start using the C9X format for long long ("%lld" IIRC)
 instead of the BSD extension "%qd".  Removing the special support for
 "%qd" from gcc would be a good start.
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Mar 29 18:00:17 PST 1999 
State-Changed-Why:  
Asked and answered. 
>Unformatted:
