Fix for 687420, /rangecheck in initgraphics with /Orientation != 0

Alex Cherepanov <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Coscript Software
Message-ID <[email protected]>
[LOG MESSAGE]
Prevent GCC with -ffast-math from converting a/90. into a*(1/90.) .
Fix bug 687420

I think this is the easiest solution. This code has been running fine
on a wide variety of compilers and systems for years. I don't see the
need to do radical changes now. Thanks to Daniel Glöckner for
discovering and analyzing the problem.

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
gsmisc.c.diff (text/plain, 1 KB)
Index: gs/src/gsmisc.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsmisc.c,v
retrieving revision 1.15
diff -b -u -r1.15 gsmisc.c
--- a/gs/src/gsmisc.c	23 Sep 2002 01:21:02 -0000	1.15
+++ b/gs/src/gsmisc.c	9 May 2004 14:58:09 -0000
@@ -1141,10 +1141,13 @@
 static const int isincos[5] =
 {0, 1, 0, -1, 0};
 
+/* Prevent GCC with -ffast-math from converting ang/90. into ang*(1/90.) */
+static double const_90_degrees = 90.;
+
 double
 gs_sin_degrees(double ang)
 {
-    double quot = ang / 90;
+    double quot = ang / const_90_degrees;
 
     if (floor(quot) == quot) {
 	/*
@@ -1159,7 +1162,7 @@
 double
 gs_cos_degrees(double ang)
 {
-    double quot = ang / 90;
+    double quot = ang / const_90_degrees;
 
     if (floor(quot) == quot) {
 	/* See above re the following line. */
@@ -1171,7 +1174,7 @@
 void
 gs_sincos_degrees(double ang, gs_sincos_t * psincos)
 {
-    double quot = ang / 90;
+    double quot = ang / const_90_degrees;
 
     if (floor(quot) == quot) {
 	/* See above re the following line. */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.