This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: bug in sprintf
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: Daniel Lidsten <Daniel dot Lidsten at combitechsystems dot com>
- Cc: ecos-discuss at sources dot redhat dot com, Knud Wöhler <woehler at ossi dot fho-emden dot de>
- Date: Mon, 2 Jun 2003 11:40:56 +0200
- Subject: Re: [ECOS] bug in sprintf
- References: <004B1D7A5257174C9044A1B7BD0E60EDA65D4E@ratatosk.combitechsystems.com>
On Mon, Jun 02, 2003 at 11:00:26AM +0200, Daniel Lidsten wrote:
> Hi,
>
> I can see the same problem with printf and fprintf i.e. i cant print negative interger values.
printf, fprintf, *print* all end up calling the same function,
vfnprintf. If that has a problem, everything else will have a problem.
> Is the below change a recomended fix (remove the line?)
It looks like a compiler bug, so the proper fix is to fix the
compiler, probably the optimizer. If it gets it wrong here, where else
is it getting it wrong?
[...]
> > I think because size_t is unsigned it should not be handled in SARG().
I disagree. http://www.opengroup.org/onlinepubs/007904975/
The section about sprintf says:
z Specifies that a following d , i , o , u , x , or X conversion
specifier applies to a size_t or the corresponding signed integer
type argument; or that a following n conversion specifier applies
to a pointer to a signed integer type corresponding to a size_t
argument.
Thus %zd is valid and SARG() has to deal with it.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss