Hello,
Here is a surprising bug I discovered. It's about variables of the set type in procedures.
---------------------------------------------------------------------------- -- Program SetBug2;
Procedure Try; Var X : Integer = 1; OneSet : Set Of Integer = [1]; Begin If X In OneSet Then Writeln('OK') End; Begin Try End. ---------------------------------------------------------------------------- --
If I define 'OneSet' like this : Const OneSet = [1]; the problem disappears...
And if the main program is : Var X : Integer = 1; OneSet : Set Of Integer = [1]; Begin If X In OneSet Then Writeln('OK') End. there is no problem.
Here is my command line : gpc -v SetBug.pas -o SetBug.exe
And the output is : ---------------------------------------------------------------------------- -- Reading specs from c:/djgpp/lib/gcc-lib/djgpp/2.952/specs gpc version 20000727, based on 2.95.2 19991024 (release) c:/djgpp/lib/gcc-lib/djgpp/2.952/gpcpp.exe -lang-pascal -v -famtmpfile=c:/djgpp/tmp\ccai2csi -fdelphi-comments -D__GNU_PASCAL__ -undef -D__GNUC__=2 -D__GNUC_MINOR__=95 -D__GPC__=2 -D__GPC_MINOR__=0 -D__GPC_RELEASE__=20000727 -D__BITS_LITTLE_ENDIAN__=1 -D__BYTES_LITTLE_ENDIAN__=1 -D__WORDS_LITTLE_ENDIAN__=1 -Dunix -Di386 -DGO3 2 -DDJGPP=2 -DMSDOS -D__OS_DOS__=1 -D__unix__ -D__i386__ -D__GO32__ -D__DJGPP__=2 -D__MSDOS__ -D__OS_DOS__=1 -D__unix -D__i386 -D__GO32 -D__DJGPP=2 -D__MSDOS -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentium__ -imacros c:/djgpp/lib/../include/sys/version.h -remap SetBug2.pas c:/djgpp/tmp\ccbi2csi.i GNU Pascal Compiler PreProcessor version 2.95.2 19991024 (release) (80386, BSD syntax) #include "..." search starts here: #include <...> search starts here: c:/djgpp/lang/pascal c:/djgpp/include c:/djgpp/contrib/grx232/include /usr/local/include JDIR/i586-pc-msdosdjgpp/include $DJDIR/lib/gcc-lib/djgpp/2.952/include $DJDIR/include End of search list. c:/djgpp/lib/gcc-lib/djgpp/2.952/gpc1.exe c:/djgpp/tmp\ccbi2csi.i -quiet -dumpbase SetBug2.pas -version -famtmpfile=c:/djgpp/tmp\ccai2csi -o c:/djgpp/tmp\ccbi2csi.s GNU Pascal version 2.95.2 19991024 (release) (djgpp) compiled by GNU C version 2.95.2 19991024 (release). SetBug2.pas: In function `Try': SetBug2.pas:7: Internal compiler error in `get_set_constructor_bits', at tree.c:5016 Please submit a full bug report. See URL:http://www.gnu.org/software/gcc/faq.html#bugreport for instructions. ----------------------------------------------------------------------------
-- «Couperin»
f.couperin wrote:
Hello,
Here is a surprising bug I discovered. It's about variables of the set type in procedures.
-- Program SetBug2;
Procedure Try; Var X : Integer = 1; OneSet : Set Of Integer = [1]; Begin If X In OneSet Then Writeln('OK') End; Begin Try End.
Since GPC stores sets as bitfields, a full set of Integer would take 512 MB on a 32 bit system (and much more on a 64 bit system). Of course, the compiler should not crash (couper11.pas).
To solve the problem, declare the set of a more appropriate subrange type. This will also be necessary when this particular bug will be fixed. Maybe in the future, GPC will support a more compact representation for "sparse" sets, so the above will actually work, but that's not a top priority...
Frank