Mingeborg | 1 Jul 2004 08:07
Picon
Favicon

problem with writeln (or program bug?)

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. 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.

The program is hardwired to compute the largest independent set of a path with 2 vertices, and the output
(Continue reading)

Russell Whitaker | 1 Jul 2004 08:06

gpc+gcc-3.3.4

Hi

downloaded gcc-3.3.4 today.
building gcc-20040516 with Waldek's Make-lang.in patch,

configure --enable-languages=c,c++,pascal

test results:

Unsupported: regextest.pas
# of tests             3910
# of expected passes   3909
# of unsupported tests 1

gpc version 20040516, based on gcc-3.3.4

Good.
Thanks,
  Russ

willett | 1 Jul 2004 09:39
Picon
Favicon

unbuffered read from terminal

Advice sought on terminal input to a  gpc program:

I'm trying to read character at a time from the terminal, to allow my 
program to
respond to each keystroke when typed.  Also, I don't want to hang 
waiting for
input if nothing has  been typed.

Thus I'm using IOSelectRead  with  a timeout.  (excessive timeout,
below, just for testing.)    My test program below
works, but keyboard typing is line buffered, that is, it doesn't know 
the user has
typed anything (returns with SelectValue=1) unless a Return has been 
typed.

----------------------
program ios (input,output);
import GPC;
var
  SelectValue: Integer;
   microsec: Integer;
   SelectInput: array [1 .. 1] of PAnyFile = ( <at> Input);
begin
       SelectValue := IOSelectRead (SelectInput, 2000000);
       writeln('selectvalue=', SelectValue:5);
end.
----------------------

I don't want to use the CRT unit, because that disturbs terminal's 
processing of
(Continue reading)

Frank Heckenbach | 2 Jul 2004 04:13
Picon

Re: problem with writeln (or program

Mingeborg <at> 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;}
(Continue reading)

Frank Heckenbach | 2 Jul 2004 03:56
Picon

Re: unbuffered read from terminal

willett wrote:

> Advice sought on terminal input to a  gpc program:
> 
> I'm trying to read character at a time from the terminal, to allow my 
> program to
> respond to each keystroke when typed.  Also, I don't want to hang 
> waiting for
> input if nothing has  been typed.
> 
> Thus I'm using IOSelectRead  with  a timeout.  (excessive timeout,
> below, just for testing.)    My test program below
> works, but keyboard typing is line buffered, that is, it doesn't know 
> the user has
> typed anything (returns with SelectValue=1) unless a Return has been 
> typed.
>
> I don't want to use the CRT unit, because that disturbs terminal's 
> processing of
> escape sequences, e.g. for VT102 ANSI sequences.

Not really disturbs. It interprets them and returns key codes for
them (on input) or converts screen drawing to the sequences (on
output).

> (Incidentally, I'm
> running on Macintosh OSX, using terminal.

Are you sure your program will always run on this terminal? Not
perhaps sometime on another machine, or just another terminal via
(Continue reading)

Mingeborg | 2 Jul 2004 06:53
Picon
Favicon

Re: problem with writeln (or program

How embarrassing -  -O -W -Wall indeed found the problem with the program.
Thank you very much!
- Inga

In a message dated 7/1/2004 10:13:57 PM Eastern Daylight Time, Frank Heckenbach <ih8mj <at> fjf.gnu.de> writes:

>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

Russell Whitaker | 3 Jul 2004 08:13

gpc+gcc-3.4.1

Hi

gcc-3.4.1 was released July 1.
Should I try building gpc with it at this time?

Thanks,
  Russ

Frank Heckenbach | 4 Jul 2004 22:41
Picon

Re: problem building GPC 20040516 on AIX -

I wrote:

> Gert Doering wrote:
> 
> > ../.././xgpc -B/s1/gpc-build/gcc/  -I../rts --automake --executable-file-name -W -Wall
-Wmissing-prototypes -Wmissing-declarations -g -O2 --executable-path=. 
--unit-path=/s1/gcc-3.2.3/gcc/p/rts --unit-path=/s1/gcc-3.2.3/gcc/p/units `cat
needed-options` "/s1/gcc-3.2.3/gcc/p/utils/binobj.pas"
> > ld: 0711-317 ERROR: Undefined symbol: Tempdirectory.1
> > ld: 0711-317 ERROR: Undefined symbol: Tempstr.4
> > ld: 0711-317 ERROR: Undefined symbol: Buffer.8
> > ld: 0711-317 ERROR: Undefined symbol: Zero.3
> > ld: 0711-317 ERROR: Undefined symbol: Epoch.6
> > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> > information.
> > collect2: ld returned 8 exit status
> 
> I think I know what's causing this (probably a GPC bug). I'm
> trying to solve it, will report soon (I hope) ...

For now, I'm afraid I only have a work-around for this problem in
the RTS. With this applied, I get these results -- all of the
failures are for the same reason (static local variables of schema,
string or file type). I hope I can provide a better solution soon,
but since this isn't common in normal code (and not standard,
anyway), GPC should be mostly usable this way.

UNSUPPORTED: asmtest.pas
FAIL: bo4-18.pas
UNSUPPORTED: crttest.pas
(Continue reading)

Gert Doering | 6 Jul 2004 16:13
Picon
Favicon

Re: problem building GPC 20040516 on AIX - workaround works!

Hi,

(answering two mails in one)

On Sun, Jun 27, 2004 at 08:35:40PM +0100, Frank Heckenbach wrote:
> Gert Doering wrote:
> 
> > In the meantime, I tried something else - gcc-3.2.3 with gpc-20040516,
> > again on AIX 5.1 and additionally on AIX 5.2 (in case AIX 5.1 is broken).
> 
> Incidentally I also have to build GPC on AIX 5 at the moment
> (powerpc-ibm-aix5.1.0.0).

Lucky me :-)

> Although gcc-3.2.1 was already installed on the system, building
> with it didn't seem to work (unrecognizable insn). So I did this ...

Interesting.  With gcc-3.3.1, *these* problems didn't happen for me.

[..]
> > The effect is quite different here.  It builds all of xgpc and the
> > libgpc.a just fine, but then crashes in trying to build "binobj".
> 
> (BTW, I wouldn't call an error message a crash. To me a crash is a
> segfault or something like this.)

"The build process aborted in an unexpected way".  However :-)

[..]
(Continue reading)

Adriaan van Os | 6 Jul 2004 17:03
Picon
Favicon

Re: problem building GPC 20040516 on AIX - workaround works!

Gert Doering wrote:

> So, thank you very much for the workaround.  We will have to rewrite
> parts of the software (some modules actually use static String and FILE
> variables), but we expect much more issues with structure alignment and
> such, converting from AIX xlp to gpc...

gpc has the maximum-field-alignment compiler directive: 
$maximum-field-alignment=value, where value= 8, 16, 32 (or 0 for the 
default). This even works with $local end $endlocal !

I don't know whether this is helpful or not (as I have no knowledge of 
AIX or xlp).

Regards,

Adriaan van Os


Gmane