http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59774
--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- Very interesting and good sleuthing! The way this is suppose to work: For G formatting, we compute the equivalent F or E formatting, as defined in the standard, and pass this new format to output_float which then uses the regular existing formatting processes to do the work. This line: (on or about line 1105 in write_float.def newf.u.real.d = m == 0.0 ? d - 1 : -(mid - d - 1) ;\ is suppose to compute the new 'd' from mid and the given "d" and pass that into output_float using the newf fnode structure. In the failing case the new 'd' is being set to zero and being passed on. As far as your 'kludge'. I don't think of it that way, but we should see if there is a way to correctly compute the d_o value where you are using it in output_float. There should be a way. Since the standard defines all we do in terms of F and E formatting, I think we are mishandling something there in output_float. You are very close to the solution here. (of course I could be wrong). Someone on the list once said, if it fixes the bug, its probably good enough. The computer has no feelings about "correctness" of approach.