This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug in sprintf


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]