Problem in printf float values in range (-1 value 1)

2010-02-18 Thread Naveen H. S
Hi,

We are porting gcc toolchain for a new target. Most of the functionalities
are working fine as expected. However, there is one issue regarding the 
printf function.

Issue
-
Float variables are prefixed by some garbage value in printf function. 
However, the values are generated correctly when seen through GDB.
Ex:- If the expected result is 0.456
RUN OUTPUT - 0.00456 (INCORRECT)
GDB OUTPUT - 0.456 (CORRECT)

The above issue is observed only with the float variables less than one.
i.e. error result if  (-1  value  1)
The values are displayed correctly if the value does not fall in above 
range. 
Ex:- If the expected result is 1.456
RUN OUTPUT - 1.456 (CORRECT)
GDB OUTPUT - 1.456 (CORRECT)

The above mentioned issue was not observed with gcc-3.4.4. However, on
porting to gcc-4.4.1; we are observing this issue.

Please let me know if there is anything missing in the port that would
possibly result in above incorrect behavior.

Thanks  Regards,
Naveen.H.S
www.kpitgnutools.com




Re: Problem in printf float values in range (-1 value 1)

2010-02-18 Thread Dave Korn
On 18/02/2010 10:11, Naveen H. S wrote:

 Issue
 -
 Float variables are prefixed by some garbage value in printf function. 
 However, the values are generated correctly when seen through GDB.
 Ex:- If the expected result is 0.456
 RUN OUTPUT - 0.00456 (INCORRECT)
 GDB OUTPUT - 0.456 (CORRECT)
 
 The above issue is observed only with the float variables less than one.
 i.e. error result if  (-1  value  1)
 The values are displayed correctly if the value does not fall in above 
 range. 
 Ex:- If the expected result is 1.456
 RUN OUTPUT - 1.456 (CORRECT)
 GDB OUTPUT - 1.456 (CORRECT)
 
 The above mentioned issue was not observed with gcc-3.4.4. However, on
 porting to gcc-4.4.1; we are observing this issue.

  It's hard to imagine that this could be some kind of bug in the compiler's
argument passing that was causing this effect, much more likely that there's a
bug in your libc printf code, possibly some undefined behaviour that has only
become a problem because of improvements to the optimisers in series 4; you'll
probably have to debug your printf routine to see where it's going wrong.

cheers,
  DaveK