Hi,
Testing gpc-20021111 I have hit a problem trying to remove duplicate variables. I've produced a cut-down example and the two sources are:-
mgcd_module.pas =============== module mgcd_module interface; export mgcd_module = all; var statfile : text; end. module mgcd_module implementation; end.
mgcd_program.pas ================ program mgcd_program; import mgcd_module; #if __GPC_RELEASE__ < 20021111 var statfile : text; #endif begin rewrite(statfile, 'mgcd.statfile'); writeln(statfile, 'some stats'); end.
I build and run with the command sequence:-
gpc -c mgcd_module.pas gpc -c mgcd_program.pas gpc mgcd_program.o mgcd_module.o a.out
and I get a core dump with gpc-20021111. I used to get a core dump with earlier versions until I used the kludge of the duplicate variable - but this is now illegal. The underlying problem appears to be something to do with file data structures not being initialized.
Thus the above works with:-
gpc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs gpc version 2.1 (20020510), based on gcc-2.8.1
but fails with:-
gpc -v Reading specs from /ClearCase_01/mgcd/gcc-3.1.1_gpc-20021111_install.dir/lib/gcc-lib/sparc-sun- solaris2.6/3.1.1/specs Configured with: /ClearCase_01/mgcd/gcc-3.1.1/configure --prefix=/ClearCase_01/mgcd/gcc-3.1.1 _gpc-20021111_install.dir : (reconfigured) /ClearCase_01/mgcd/gcc-3.1.1/configure --prefix=/ClearCase_01/mgcd/gcc-3.1.1 _gpc-20021111_install.dir Thread model: posix gpc version 20021111, based on gcc-3.1.1
Hopefully someone can tell me how I can solve/workaround this problem.
Martin G C Davies
On Sat, 30 Nov 2002, Martin G C Davies wrote:
Hi,
Testing gpc-20021111 I have hit a problem trying to remove duplicate variables. I've produced a cut-down example and the two sources are:-
mgcd_module.pas
module mgcd_module interface; export mgcd_module = all; var statfile : text; end. module mgcd_module implementation; end.
mgcd_program.pas
program mgcd_program; import mgcd_module; #if __GPC_RELEASE__ < 20021111 var statfile : text; #endif begin rewrite(statfile, 'mgcd.statfile'); writeln(statfile, 'some stats'); end.
I build and run with the command sequence:-
gpc -c mgcd_module.pas gpc -c mgcd_program.pas gpc mgcd_program.o mgcd_module.o a.out
and I get a core dump with gpc-20021111. I used to get a core dump with earlier versions until I used the kludge of the duplicate variable - but this is now illegal. The underlying problem appears to be something to do with file data structures not being initialized.
Adding -g0 to the compile stmts gets rid of the dump and you should get:
a.out: `Unbind' applied to non-bindable TFDD file `(null)' (error #404 at 8049c14)
Hopes this helps, Russ
Martin G C Davies wrote:
[...]
and I get a core dump with gpc-20021111. I used to get a core dump with earlier versions until I used the kludge of the duplicate variable - but this is now illegal. The underlying problem appears to be something to do with file data structures not being initialized.
Indeed, this is a known bug with modules (same as with strings in module interfaces). The kludge with the duplicate variable worked because it effectively made the variable belong to the main program (where initialization works) and gave the module an external declaration. (Of course, this was not realiable, since in the future (with qualified identifiers) it would be two distinct variables.) A similar kludge could be realized now by giving both declaration different identifiers, but the same asmname ...
A better kludge would be to use units, or to explicitly initialize the variable in the module:
to begin do Initialize (statfile);
Frank