[ N.B. This bug strikes on a Sun 3 running SunOS 4 with the cc -O4 option
as well as on the sparc. -Mike ]
Date: Fri, 24 Feb 89 15:36:40 -0600
To: mike@wheaties.ai.mit.edu
From: Dave Cohrs <dave@cs.wisc.edu>
Subject: bug + fix in gnu grep 1.2 (from prep.ai.mit.edu)
I tried installing the GNU grep 1.2 on a Sun4 running 4.0.1 and
"Spencer test #36" failed. After some experimenting, I found and
fixed the bug. Well, actually, the bug in the the C compiler, but
The Sun4 4.0.1 C compiler with -O doesn't generate the correct for
To be exact, "y;" gets executed, while "x;" should. This causes the
#define FETCH() to fail for test #36.
In an #ifdef sparc in dfa.c, I made two versions of FETCH, FETCH0() and
the regular FETCH(). The former takes only one argument, the latter
expects its 2nd argument to contain a non-nil string. This removes
the need to test the constant strings, and the compiler bug isn't
exercised. I then changed the one instance of FETCH() with a nil
second argument to be FETCH0() instead.
===================================================================
*** /tmp/,RCSt1a05930 Fri Feb 24 15:32:33 1989
--- dfa.c Fri Feb 24 15:23:34 1989
/* Note that characters become unsigned here. */
+ * Sun4 4.0.1 C compiler can't compare constant strings correctly.
+ * e.g. if("test") { x; } else { y; }
+ * the compiler will not generate code to execute { x; }, but
+ * executes { y; } instead.
+ (c) = (unsigned char) *lexptr++; \
#define FETCH(c, eoferr) \
+ (c) = (unsigned char) *lexptr++; \
+ #define FETCH(c, eoferr) \
(c) = (unsigned char) *lexptr++; \