Hello,
I tried to reduce a program I couldn''t compile. You'll see it below. I'm wondering if I made a mistake or if it's really a bug.
I found that the problem comes from : P_Vecteur = ^T_Vecteur = Nil; (Everything is fine if I suppress the "= Nil".) In other programs, this declaration doesn't cause any problem, even if P_Vecteur is the argument of a procedure (and here there is no problem until the last procedure). Is it something I should avoid ?
Here is the output of GPC :
./temp24_u2.pas: In procedure `Diffvecteurs': ./temp24_u2.pas:29: initial value is of wrong type gpc1.exe: c:/djgpp/bin/gpc.exe exited with status 1
or
it may say also : ./temp24_u2.pas: In procedure `Diffvecteurs': ./temp24_u2.pas:29: incompatible types in initialization ./temp24_u2.pas:29: initial value is of wrong type gpc1.exe: c:/djgpp/bin/gpc.exe exited with status 1
and from time to time :
Exiting due to signal SIGSEGV General Protection Fault at eip=00172911 ...
(GNU Pascal v 2.1 alpha (20020910) with DJGPP, on WindowsME)
****************************** Program temp24;
Uses temp24_u2;
Begin End. ****************************** Unit temp24_u2;
Interface
Type P_Vecteur = ^T_Vecteur = Nil; T_Vecteur(N:Cardinal) = Array [1..N] Of LongReal;
Implementation
Procedure AddVecteurs(Resultat,A,B:P_Vecteur); Var Taille : Integer; Tampon : P_Vecteur; Procedure Addition(Resultat,AA,BB:P_Vecteur); Var I : Integer; Begin For I := 1 To Taille Do Resultat^[I] := AA^[I] + BB^[I] End; Begin End;
Procedure DiffVecteurs(Resultat,A,B:P_Vecteur); Var Taille : Integer; Tampon : P_Vecteur; Procedure Soustraction(Resultat,AA,BB:P_Vecteur); Var K : Integer; Begin For K := 1 To Taille Do Resultat^[K] := AA^[K] - BB^[K] End; Begin End;
Begin End. ******************************
Couperin wrote:
I tried to reduce a program I couldn''t compile. You'll see it below. I'm wondering if I made a mistake or if it's really a bug.
I found that the problem comes from : P_Vecteur = ^T_Vecteur = Nil; (Everything is fine if I suppress the "= Nil".) In other programs, this declaration doesn't cause any problem, even if P_Vecteur is the argument of a procedure (and here there is no problem until the last procedure). Is it something I should avoid ?
Here is the output of GPC :
./temp24_u2.pas: In procedure `Diffvecteurs': ./temp24_u2.pas:29: initial value is of wrong type gpc1.exe: c:/djgpp/bin/gpc.exe exited with status 1
It's a GPC bug. I've fixed it (wait for the next release). Thanks for the report. (couper13.pas)
As an aside: As you may have read, Waldek Hebisch and I are working on the port to gcc-3 (it's not completely stable yet, but partially usable). One of the major drawbacks of gcc-2 is the internal memory management system ("obstacks") which has caused us many toubles in GPC. This bug, again, was related to obstacks, so in fact your test worked already with the gcc-3 based GPC. However, I've now fixed the real problem so it also works with obstacks (which was also necessary to fix a related problem I discovered while debugging it (fjf704.pas) and to made the code cleaner, anyway).
Frank