Waldek Hebisch a écrit:
I have put a new gpc snapshot at:
When recompiling my programs with djgpp built snapshot, both with gcc 3.4.4 and gcc 4.1.2 backends (both uploaded) I have found two new bugs (not present with gpc 20060325 /gcc 3.4.4)
Reducing to smallest possible test programs they are
1/ ======================================================
Problem with recursive definition or operators
Occurs for both backends
Two programs display the bug
---------------------------------------------------------
program powrecur;
var r: real;
operator power(r: real; n:integer) y: real; begin if n < 0 then y := 1 / (r power (0-n)) else y := r pow n end;
begin r := 10; if abs ( r power(-2) - r pow (-2) ) < epsreal then write('OK') else write('failed') end.
--------------------------------------------------------------
program minrecur;
var i,j: integer;
operator minus (a,b: integer) = y: integer; begin if b < 0 then y := -( (0-a) minus (0-b) ) else y := a - b end;
begin i := -10; j := -10; if i minus j = 0 then write('OK') else write('failed') end.
---------------------------------------------------------------
They give similar error messages
minrecur.pas: In operator `minus (integer, integer)': minrecur.pas:7: error: invalid use of operator `minus'
Notice that (0-n) (0-a) (0-b) instead of (-n) (-a) (-b) where necessary in the previous (20060325) snapshot, which compiles these programs (ang gives good results with more complicated arguments).
Work around is easy, but a fix would be better.
2/ ============================================================
Occurs only with 4.1.2 backend.
The test program is composed of two files
--------------------------------------------------------------
program strg;
uses ustrg;
begin if n = Un then write('OK') else write('failed'); end.
---------------------------------------------------
unit ustrg;
INTERFACE
function str2int(const s: string) = i : integer;
var Un : integer = str2int('1'); n : integer;
IMPLEMENTATION
function str2int(const s: string) = i : integer; begin ReadStr(s,i) end;
begin n := str2int('1'); end.
-------------------------------------------------
The error message is
c:\lombardi\djgpp\o/ustrg.o: In function `_p__M5_Ustrg_init': ustrg.pas:11: undefined reference to `__p__M5_Ustrg_S1_tmp_string_0' ustrg.pas:18: undefined reference to `__p__M5_Ustrg_S1_tmp_string_0' ustrg.pas:18: undefined reference to `__p__M5_Ustrg_S1_tmp_string_0' ustrg.pas:11: undefined reference to `__p__M5_Ustrg_S1_tmp_string_0' ustrg.pas:11: undefined reference to `__p__M5_Ustrg_S2_nonconstant_expr_1' collect2: ld returned 1 exit status
-------------------------------------------------------------
it seems to occur only with this dual initialisation: one directly in the interface one in the initialization part of the unit. and only with strings changing to a given fixed length string or to a local made (instead of internal) function WriteStr changes nothing
Hope this helps
Maurice