Sorry, I am systematically trying out all available compiler options, this time --setlimit ...
[G4:~/gnu/testgpc/adriaan] adriaan% cat setlimit.pas program setlimit; type intset = set of integer; bigset = set of 0..100000; begin writeln( 'SizeOf( set of integer) = ', SizeOf( intset)); writeln( 'SizeOf( bigset) = ', SizeOf( bigset)); end.
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit setlimit.pas setlimit.pas:2: warning: constructing limited integer set `-2147483648 .. -2147483393'; setlimit.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit.pas:3: warning: constructing limited integer set `0 .. 255'; setlimit.pas:3: warning: use `--setlimit=NUMBER' to change the size limit at compile time.
The second warning is correct, the first a bit misleading, as it suggests construction of a very large set ...
[G4:~/gnu/testgpc/adriaan] adriaan% ./setlimit SizeOf( set of integer) = 32 SizeOf( bigset) = 32
... but both sets have regular sizes.
The --setlimit argument changes the upper limit of the sets ...
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit setlimit.pas --setlimit=10000 setlimit.pas:2: warning: constructing limited integer set `-2147483648 .. -2147473649'; setlimit.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit.pas:3: warning: constructing limited integer set `0 .. 9999'; setlimit.pas:3: warning: use `--setlimit=NUMBER' to change the size limit at compile time.
... but the warning is the same. The set sizes are correct:
[G4:~/gnu/testgpc/adriaan] adriaan% ./setlimit SizeOf( set of integer) = 1252 SizeOf( bigset) = 1252
However, there seems to be a problem with the implementation ...
[G4:~/gnu/testgpc/adriaan] adriaan% cat setlimit2.pas program setlimit2; type intset = set of integer; bigset = set of 0..100000; const i: intset = [ - 1]; b: bigset = [ 100000]; begin end.
This produces an internal compiler error when used with --setlimit ...
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit2 setlimit2.pas --setlimit=1000000000 setlimit2.pas:2: warning: constructing limited integer set `-2147483648 .. -1147483649'; setlimit2.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit2.pas:5: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See URL:http://gcc.gnu.org/bugs.html for instructions.
Without --setlimit, the results are correct (the invalid set initializers are detected)
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit2 setlimit2.pas setlimit2.pas:2: warning: constructing limited integer set `-2147483648 .. -2147483393'; setlimit2.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit2.pas:3: warning: constructing limited integer set `0 .. 255'; setlimit2.pas:3: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit2.pas:5: error: invalid set initializer setlimit2.pas:6: error: invalid set initializer
Regards,
Adriaan van Os
On Thu, Aug 07, 2003 at 01:39:12PM +0200, Adriaan van Os wrote:
Sorry, I am systematically trying out all available compiler options, this time --setlimit ...
[G4:~/gnu/testgpc/adriaan] adriaan% cat setlimit.pas program setlimit; type intset = set of integer; bigset = set of 0..100000; begin writeln( 'SizeOf( set of integer) = ', SizeOf( intset)); writeln( 'SizeOf( bigset) = ', SizeOf( bigset)); end.
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit setlimit.pas setlimit.pas:2: warning: constructing limited integer set `-2147483648 .. -2147483393'; setlimit.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit.pas:3: warning: constructing limited integer set `0 .. 255'; setlimit.pas:3: warning: use `--setlimit=NUMBER' to change the size limit at compile time.
The second warning is correct, the first a bit misleading, as it suggests construction of a very large set ...
[G4:~/gnu/testgpc/adriaan] adriaan% ./setlimit SizeOf( set of integer) = 32 SizeOf( bigset) = 32
... but both sets have regular sizes.
-2147483393 - (-2147483648) = 255 = 8 * 32 - 1, so where's the problem?
Emil
Emil Jerabek wrote:
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit setlimit.pas setlimit.pas:2: warning: constructing limited integer set `-2147483648 .. -2147483393';
-2147483393 - (-2147483648) = 255 = 8 * 32 - 1, so where's the problem?
You are quite right, I hadn't seen that the second number was negative also.
Regards,
Adriaan van Os
Adriaan van Os wrote:
Sorry, I am systematically trying out all available compiler options,
I know. ;-)
The --setlimit argument changes the upper limit of the sets ...
Yes, that's what it's supposed to do. (In general, it would be hard to guess if it's more reasonable to change the lower or upper limit, so we always change the upper one.)
However, there seems to be a problem with the implementation ...
[G4:~/gnu/testgpc/adriaan] adriaan% cat setlimit2.pas program setlimit2; type intset = set of integer; bigset = set of 0..100000; const i: intset = [ - 1]; b: bigset = [ 100000]; begin end.
This produces an internal compiler error when used with --setlimit ...
[G4:~/gnu/testgpc/adriaan] adriaan% gpc -o setlimit2 setlimit2.pas --setlimit=1000000000 setlimit2.pas:2: warning: constructing limited integer set `-2147483648 .. -1147483649'; setlimit2.pas:2: warning: use `--setlimit=NUMBER' to change the size limit at compile time. setlimit2.pas:5: internal compiler error: Segmentation fault
The problem is that the backend tries to allocate the memory for the set on the stack (several calls to `alloca' in varasm.c and at least one in tree.c). Since the backend doesn't seem to limit the size of set types to "small" types (at least tree.def doesn't seem to say so), this seems to be a backend bug (you might want to report it ...).
Anyway, even with it fixed, you might not get far. It seems the backend allocates in some situations at least one byte per set element, and there may be problems if you actually go to the full integer range. It's probably not so easy to fix (and possibly not worth it), that's why we have setlimit ...
Frank