[patch. libfortran] PR33225 Per kind write float patch update, fixed

Jerry DeLisle jvdelisle@verizon.net
Tue Sep 4 05:38:00 GMT 2007


:ADDPATCH fortran:

Good news.

I found the problem.  When I re-factored the code I passed a pointer to the 
buffer used to write the exponent to the new kind independent output_float.

It has the following line:

snprintf (buffer, sizeof (buffer), "%+0*d", edigits, e);

In the original per kind patch, buffer in output_float is: char *.

Before the original patch it was: char buffer[MIN_FIELD_WIDTH+1]

sizeof (buffer) are two different things in the two versions. (yes, I am duly 
embarrassed).

The fix this is trivial; pass the size into the new output_float as well as the 
pointer buffer.  The attached updated patch does this.

Regression tested on x86-64-gnu-linux.  Added new test case which catches the 
problem.  Tested with -m64 and -m32.  Passed NIST as well.

OK for trunk?

Regards,

Jerry

2007-09-03  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

     * io/write.c (stdbool.h): Add include. (sign_t): Move typedef to
     new file write_float.def. Include write_float.def.
     (extract_real): Delete. (calculate_sign): Delete.
     (calculate_exp): Delete. (calculate_G_format): Delete.
     (output_float): Delete. (write_float): Delete.
     * io/write_float.def (calculate_sign): Added.
     (output_float): Refactored to be independent of kind and added to this
     file for inclusion. (write_infnan): New function to write "Infinite" or
     "NaN" depending on flags passed, independent of kind.
     (CALCULATE_EXP): New macro to build kind specific functions. Use it.
     (OUTPUT_FLOAT_FMT_G): New macro, likewise. Use it.
     (DTOA, DTOAL): Macros to implement "decimal to ascii".
     (WRITE_FLOAT): New macro for kind specific write_float functions.
     (write_float): Revised function to determine kind and use WRITE_FLOAT
     to implement kind specific output.








-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr33225.diff
Type: text/x-patch
Size: 37308 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070904/ae897f3b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fmt_float.f90
Type: text/x-fortran
Size: 2581 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070904/ae897f3b/attachment-0001.bin>


More information about the Gcc-patches mailing list