[BUG] GPC - a char killer?

Mon, 07 Apr 1997 01:58:26 +0200


Hallo dear Hackers,
hi Peter,

I found a bug in GPC (my version: 970401/linux/i586)?

I wrote the following little program:

{ -- the buggy program - see below ----------------}

{Warning getchar may be implemented as a macro to getc(stdin),
so this may be, this will not work for you }

program test1(input,output);

function getchar:integer; C;

var k:integer;

begin
  k:=getchar;
  while (k<>-1) do 
  begin
    writeln(k);
    k:=getchar;
  end;
end.

{--- The same as C-Source -- works ok. ---}

#include 

void main()
{ int k;
  k=getchar;
  while (k!=-1) 
    { 
       printf("%i\n",k);
       k=getchar; 
    }
}

{ --------------------------------------- }

Ok. Compiling test1.pas - no errors.
Running test1
Enter an 'N' press return you will see '78 10' - thats right.

Now the following:

echo "N">data
test1 Sven Engelhardt (sven@sik.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es