Forum > General
FPC v3.2.2 internal error
440bx:
Hello,
Consider the following sample program:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program const_internal_error; const ACONSTANT = 3; b = 5; { can do this: } {$if ACONSTANT <> b} {$MESSAGE 'ACONSTANT is not equal to b'} {$endif} type PRECORD = ^TRECORD; TRECORD = record FirstField : integer; SecondField : DWORD; end; const { can define constants that represent the field offsets } RECORD_FIRSTFIELD_OFFSET = @PRECORD(nil)^.FirstField; RECORD_SECONDFIELD_OFFSET = @PRECORD(nil)^.SecondField; { CAN NOT do this: } {$if RECORD_FIRSTFIELD_OFFSET <> 5} {$MESSAGE 'RECORD_FIRSTFIELD_OFFSET is not equal to 5'} {$endif} { NOR this: } {$if RECORD_FIRSTFIELD_OFFSET <> RECORD_SECONDFIELD_OFFSET} {$MESSAGE 'RECORD_FIRSTFIELD_OFFSET is not equal to RECORD_SECONDFIELD_OFFSET'} {$endif} begin readln;end. In line 10, the preprocessor is comparing two constants without any problems.
In lines 31 and 37, constants are being compared and in both cases the compiler emits an internal error.
Refer to the attachment to see a snapshot of the compiler messages including the internal error.
To see the error produced by the second comparison (the "NOR this:" one), comment out the first comparison.
It would be very nice if this problem did not occur in the upcoming v3.2.4
bytebites:
What do you expect; You can't compare pointer to integer
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var x:pointer;begin if x=5 then end;
--- Quote --- Error: Operator is not overloaded: "^untyped" = "ShortInt"
--- End quote ---
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- RECORD_FIRSTFIELD_OFFSET = int64(@PRECORD(nil)^.FirstField); RECORD_SECONDFIELD_OFFSET = int64(@PRECORD(nil)^.SecondField);
ALLIGATOR:
FPC [main] https://gitlab.com/freepascal.org/fpc/source/-/commit/c2b8089bf4d890729f7d9e6c8d9330a92324e79b
the same
Error: Internal error 2013112802
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program const_internal_error; const ptr = nil; {$if ptr <> 5}{$endif} beginend.
Related:
https://gitlab.com/freepascal.org/fpc/source/-/issues/25573
https://gitlab.com/freepascal.org/fpc/source/-/issues/25296
Martin_fr:
As indicated there is an issue comparing pointers. I had similar issues recently. Casting to PtrUInt or PtrInt **should** solve it.
Of course "internal error" still is a bug.
Maybe related to https://gitlab.com/freepascal.org/fpc/source/-/issues/41460 (I had tried the subtraction in a "const" section first... / but apparently any "pointer - pointer")
PascalDragon:
--- Quote from: 440bx on November 08, 2025, 01:18:09 pm ---It would be very nice if this problem did not occur in the upcoming v3.2.4
--- End quote ---
Considering that according to ALLIGATOR that's not even fixed in main, very unlikely. Please report a bug.
Navigation
[0] Message Index
[#] Next page