Mingeborg@aol.com wrote:
Enclosed is a gzipped tar file containing program ind.p (298 lines.)
As is, the program goes into infinite recursion, but it works correctly if you comment out a âÂÂwritelnâ statement on line 248, (the statement before ***************...) (gpc-20040516, Linux running on a Pentium 4 laptop.)
I apologize for the size of the example, but I have been unable to reproduce the problem with a smaller example, and I don't understand what is happening.
The following are lines 238 â 249 of the program. ... function rcrsv_ind_st2(var g:relation; s:subset): subset; {this one is not debugged yet.
It's generally not very advisable to post code that may be buggy itself. Of course, given GPC's history, a compiler bug is quite possible, but so is a program bug, and a relatively short Pascal program is much easier to debug than the compiler.
gives different result than rcrs2 for the third fullerene}
var i,k,l,k1,k2 :integer; nb,ind1,ind2 :subset; iterations :integer=0; attribute (static); begin {writeln('top:'); diagnose_subset(s); stop_n_go;} iterations := iterations+1; writeln('iteration number:',iterations); {************ comment this out, and it works ********} if not there_are_edges_in(s,g) ...
This particular code works correctly on DIGITAL Pascal, (after changing the syntax for the static variable declaration,) but âÂÂwritelnâ statements in âÂÂwrongâ (but different) places have the same effect there, also.
You mean it also recurses endlessly there? That would be a strong indication for a program bug. Otherwise you'd have found a GPC bug and a different Digital Pascal bug in the same short code ...
Is it possible that, under certain circumstances, âÂÂwritelnâ permanently changes register values, or some such?
What do you mean with register values? Assembler level registers? Of course, almost every operation changes them. Pascal variables? If they have a defined value, an operation without side-effects on them shouldn't change them, of course. (Otherwise it's in fact a compiler bug.)
*However*, if the variables are undefined, any operation can change their accidental values. That's what undefined means.
So I'd first look for this in your code. Did you compile with all warnings on, for a start? Please note that GPC doesn't find some such cases unless you compile with optimization. So `-O -W -Wall' would be a good start.
Frank