Reopening.
I have received a report that 5.6.2 (which includes the fix above) breaks with the following error with a mode=map request with mapext=2701967.5295031+1184936.875+2705055.4704969+1186876.375
msDrawMap(): Image handling error. Failed to draw layer named 'ownershipqpoly'.
msPostGISLayerWhichShapes(): Query error. Failed to build query SQL.
msPostGISBuildSQL(): General error message. Failed to build SQL 'where'.
msPostGISBuildSQLWhere(): General error message. Unable to build box SQL.
msPostGISBuildSQLBox: General error message. Bounding box digits truncated.
The "%.15f" format does NOT guarantee a total of 15 digits, it requests 15 digits AFTER the decimal point... so in most cases you are guaranteed to get more than 15 digits e.g.
printf("%.15f\n%.15f\n%.15f\n%.15f\n", 2701967.5295031, 1184936.875, 2705055.4704969, 1186876.375);
2701967.529503100086004
1184936.875000000000000
2705055.470496899913996
1186876.375000000000000
I think the right fix would be to use the %.15g format and account a few extra chars per coordinate for the potential use of exponential notation.