* Re: RH4.2 fort77 bug
@ 1997-07-16 16:34 Greg Lindahl
0 siblings, 0 replies; 5+ messages in thread
From: Greg Lindahl @ 1997-07-16 16:34 UTC (permalink / raw)
> Thanks for looking into these issues, by the way! I'm sure there'll
> be more than a few people who appreciate f2c being made to work
> better on Alphas, in fact being made to work better *period*.
Yes. Since C's order of evaluation is fixed, this flaw should exist
on all machines; the only reason Pentiums don't crash is because
they are not generating the fp error at all (?). It's always good
to have correct programs on all platforms, even if the bug doesn't
visibly show.
-- g
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RH4.2 fort77 bug
@ 1997-07-16 16:20 Craig Burley
0 siblings, 0 replies; 5+ messages in thread
From: Craig Burley @ 1997-07-16 16:20 UTC (permalink / raw)
>> I don't see enough evidence here to blame gcc. Are you saying
>> the `nelt->constblock.Const.cd[0] <= 0' subexpression is evaluated
>> even [if] `ISINT(nelt->headblock.vtype) && nelt->constblock.Const.ci <= 0'
>> evaluates to a non-zero result?? That's the only way I could see
>> blaming gcc, since `A && B || C' is equivalent to `(A && B) || C',
>> which in turn is equivalent to `if (A && B) 1; if (C) 1; else 0;',
>> using `1' and `0' as short-hand notation for the return value (a la
>> gcc's statement expressions).
>
>That is exactly the problem (I think?) Actually, you may be right.
>The 'ISINT()' is true and the '.ci' value is positive, which, as I
>read it, should skip out; then it still goes ahead and evaluates the
>'.cd[0]' value, which causes a FPE interrupt, since the union contains
>a NaN value and the 'cmpf' instruction traps.
No, after the .ci value is found positive, meaning the first `<='
subexpression yields 0, then the `&&' subexpression yields 0, which
means the second subexpression of the `||' subexpression *must*
be evaluated and serve as the result of the entire expression.
So, gcc is doing the right thing, it is simply an incorrectly formed
expression, and you're having a tough time reading it. This is
not surprising -- the distinction between "(A && B) || C" and
"A ? B : C" *is* a subtle one, and I've made this sort of mistake
before myself, both when reading and writing code...it's tempting
to think of the choice between B and C as being made and committed
by testing A in the former expression, but that's not the case when
A is true but B tests false, in which case C must be tested, whereas
the latter expression *does* force a choice between B and C.
Thanks for looking into these issues, by the way! I'm sure there'll
be more than a few people who appreciate f2c being made to work
better on Alphas, in fact being made to work better *period*.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RH4.2 fort77 bug
@ 1997-07-16 2:59 Craig Burley
1997-07-16 4:47 ` Greg Woodbury
0 siblings, 1 reply; 5+ messages in thread
From: Craig Burley @ 1997-07-16 2:59 UTC (permalink / raw)
>As I noted, the problem is in the GCC code generator.
>
>In "proc.c" of f2c/src the following code appears:
>
> else if ( ISINT(nelt->headblock.vtype) && nelt->constblock.Const.ci <= 0
> || nelt->constblock.Const.cd[0] <= 0 )
> dclerr("nonpositive dimension", q);
>
>And this "should" not evaluate the floating point "nelt->constblock.Const.cd[0]"
>(which is an invalid number, its a union with ints and longs, etc)
I don't see enough evidence here to blame gcc. Are you saying
the `nelt->constblock.Const.cd[0] <= 0' subexpression is evaluated
even `ISINT(nelt->headblock.vtype) && nelt->constblock.Const.ci <= 0'
evaluates to a non-zero result?? That's the only way I could see
blaming gcc, since `A && B || C' is equivalent to `(A && B) || C',
which in turn is equivalent to `if (A && B) 1; if (C) 1; else 0;',
using `1' and `0' as short-hand notation for the return value (a la
gcc's statement expressions).
Looks like a simple f2c/src coding bug to me. One that is not
an unusual sort of bug, since it's not unlike how people misword
things using English.
>I changed it to:
>
[...]
> else if ( ISINT(theVtype) && nelt->constblock.Const.ci <= 0 )
> dclerr("nonpositive dimension", q);
> else if (!ISINT(theVtype) && nelt->constblock.Const.cd[0] <= 0.0 )
> dclerr("nonpositive dimension", q);
>
>And this takes care of that problem. There are some other problems of
>this sort occurring as well, so I have a few more changes coming I guess.
I think you made essentially the correct fix, though the wrong
diagnosis regarding gcc. Note that another fix, perhaps a bit closer
to the original (wrong) code, is:
... if (ISINT(nelt->headblock.vtype)
? nelt->constblock.Const.ci <= 0
: nelt->constblock.Const.cd[0] <= 0) ...
That clarifies that the test of ISINT governs whether the .ci or
.cd field is compared to 0. You might find it easier using
the above style if you find other cases of incorrect tests involving
ISINT like the one you already found, since the above style doesn't
require any new statements or temp variables.
Please make sure you send these patches to the f2c maintainer,
<dmg@bell-lab.com> last I checked!
tq vm, (burley)
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: RH4.2 fort77 bug
1997-07-16 2:59 Craig Burley
@ 1997-07-16 4:47 ` Greg Woodbury
0 siblings, 0 replies; 5+ messages in thread
From: Greg Woodbury @ 1997-07-16 4:47 UTC (permalink / raw)
> I don't see enough evidence here to blame gcc. Are you saying
> the `nelt->constblock.Const.cd[0] <= 0' subexpression is evaluated
> even [if] `ISINT(nelt->headblock.vtype) && nelt->constblock.Const.ci <= 0'
> evaluates to a non-zero result?? That's the only way I could see
> blaming gcc, since `A && B || C' is equivalent to `(A && B) || C',
> which in turn is equivalent to `if (A && B) 1; if (C) 1; else 0;',
> using `1' and `0' as short-hand notation for the return value (a la
> gcc's statement expressions).
That is exactly the problem (I think?) Actually, you may be right.
The 'ISINT()' is true and the '.ci' value is positive, which, as I
read it, should skip out; then it still goes ahead and evaluates the
'.cd[0]' value, which causes a FPE interrupt, since the union contains
a NaN value and the 'cmpf' instruction traps.
>
> Looks like a simple f2c/src coding bug to me. One that is not
> an unusual sort of bug, since it's not unlike how people misword
> things using English.
>
> >I changed it to:
> >
> [...]
> > else if ( ISINT(theVtype) && nelt->constblock.Const.ci <= 0 )
> > dclerr("nonpositive dimension", q);
> > else if (!ISINT(theVtype) && nelt->constblock.Const.cd[0] <= 0.0 )
> > dclerr("nonpositive dimension", q);
> >
> >And this takes care of that problem. There are some other problems of
> >this sort occurring as well, so I have a few more changes coming I guess.
>
> I think you made essentially the correct fix, though the wrong
> diagnosis regarding gcc. Note that another fix, perhaps a bit closer
> to the original (wrong) code, is:
>
> ... if (ISINT(nelt->headblock.vtype)
> ? nelt->constblock.Const.ci <= 0
> : nelt->constblock.Const.cd[0] <= 0) ...
>
> That clarifies that the test of ISINT governs whether the .ci or
> .cd field is compared to 0. You might find it easier using
> the above style if you find other cases of incorrect tests involving
> ISINT like the one you already found, since the above style doesn't
> require any new statements or temp variables.
Yes! I like this form for the query, much clearer and only one
call to the dclerr() routine.
> Please make sure you send these patches to the f2c maintainer,
> <dmg@bell-lab.com> last I checked!
Yep, will do.
Greg Woodbury
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RH4.2 fort77 bug
@ 1997-07-15 20:27 Greg Woodbury
0 siblings, 0 replies; 5+ messages in thread
From: Greg Woodbury @ 1997-07-15 20:27 UTC (permalink / raw)
As I noted, the problem is in the GCC code generator.
In "proc.c" of f2c/src the following code appears:
else if ( ISINT(nelt->headblock.vtype) && nelt->constblock.Const.ci <= 0
|| nelt->constblock.Const.cd[0] <= 0 )
dclerr("nonpositive dimension", q);
And this "should" not evaluate the floating point "nelt->constblock.Const.cd[0]"
(which is an invalid number, its a union with ints and longs, etc)
I changed it to:
int theVtype;
theVtype = nelt->headblock.vtype;
.
.
.
.
else if ( ISINT(theVtype) && nelt->constblock.Const.ci <= 0 )
dclerr("nonpositive dimension", q);
else if (!ISINT(theVtype) && nelt->constblock.Const.cd[0] <= 0.0 )
dclerr("nonpositive dimension", q);
And this takes care of that problem. There are some other problems of
this sort occurring as well, so I have a few more changes coming I guess.
Greg Woodbury
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-07-16 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-07-16 16:34 RH4.2 fort77 bug Greg Lindahl
-- strict thread matches above, loose matches on Subject: below --
1997-07-16 16:20 Craig Burley
1997-07-16 2:59 Craig Burley
1997-07-16 4:47 ` Greg Woodbury
1997-07-15 20:27 Greg Woodbury
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox