Forum > FPC development

internal error 2014062901

(1/2) > >>

engkin:
The following code produces an internal error on Mac Big Sur M1 using trunk:

--- 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 project1; {$mode objfpc}{$H+} function bug(s: string): string;var  p:pointer=@s;//internal error 2014062901beginend; beginend.
Can you please check different OS/FPC version before I report it?

bytebites:
Same result on Linux 3.2 and trunk

Do you expect this result, which prints true

--- 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";}};} ---function bug(s: string): string;var  //p:pointer=@s;//internal error 2014062901  p:pointer absolute s;begin  writeln(string(p));  writeln(pchar(s)=p);end;    

engkin:
Thank you for testing.

Yes, I do expect True in this case. The record holding the length, ref count, code page ... is at a negative offset of s. Or did I miss your point?

bytebites:
Length like so

--- 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";}};} ---  writeln(PSizeInt(p-sizeof(sizeint))^=length(s));

Jonas Maebe:
While it shouldn't cause an internal error, it is an invalid expression. The reason is that @s is not constant (it's the address on the stack of the ansistring, which can be different every time the function gets called). At least FPC has no support for initialising variables with non-constant expressions.

Navigation

[0] Message Index

[#] Next page

Go to full version