Forum > FPC development

FPC internal exception

(1/2) > >>

440bx:
Hello,

This applies to the current release of FPC, i.e, v3.2.2.  when compiling the following unit:

--- 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";}};} ---{$MODESWITCH ADVANCEDRECORDS    ON}  unit ErrorHandler;  { --------------------------------------------------------------------------- }INTERFACE{ --------------------------------------------------------------------------- } type  TERROR_ID =  (   eid_no_error,    eid_uninitialized_program_data  ); type  TERROR_STATE    = record    strict private      es_procname_last_entered : pchar;   { name of last entered function/proc}      es_error                 : TERROR_ID;     public      procedure Init();      function  Errored()          : boolean;      procedure SetError(InErrorId : TERROR_ID);      procedure SetProcName(InProcName : pchar = {$I %CURRENTROUTINE%}};  end;  var  ErrorState     : TERROR_STATE;  { --------------------------------------------------------------------------- }IMPLEMENTATION{ --------------------------------------------------------------------------- }  procedure TERROR_STATE.Init();begin  es_procname_last_entered := nil;  es_error                 := eid_no_error;end;  function TERROR_STATE.Errored : boolean;begin  result := es_error <> eid_no_error;end; procedure TERROR_STATE.SetError(InErrorId : TERROR_ID);begin  es_error := InErrorId;end; procedure TERROR_STATE.SetProcName(InProcName : pchar};begin  es_procname_last_entered := InProcName;end;  end.
The compiler reports an internal exception:

--- Code: Text  [+][-]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";}};} ---[size=10pt]Verbose: Compiling ErrorHandler.pasErrorHandler.pas(33,51) Error: Compilation raised exception internallyVerbose: Compilation abortedDebug: An unhandled exception occurred at $00000001000B7860:Debug: EAccessViolation: Access violationDebug:   $00000001000B7860Debug:   $00000001000BB450Debug:   $00000001000BC0A9Debug:   $00000001000BC43EDebug:   $000000010015AC62Debug:   $00000001000E7344Debug:   $00000001000E6FDDDebug:   $00000001000E8A33Debug:   $00000001000EA924Debug:   $00000001000EAC47Debug:   $000000010017BFBEDebug:   $000000010017C624Debug:   $000000010017CE90Debug:   $00000001001601F2Debug:   $0000000100160EBDDebug:   $00000001000E669EDebug:   $000000010019D592Debug: Verbose: D:\fpcTrunk2\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode[/size]
It does not like having the {$I %CURRENTROUTINE%} as the default value for an optional parameter.

ETA:

Just to be on the safe side, this is on Windows, specifically Windows 7, 64 bit using the 64 bit version of the FPC compiler executed by Lazarus 64bit v3.99

Anything else you want to know, just ask.


440bx:
It's probably obvious what I was trying to accomplish.  Have the "SetProcName" automatically grab the function/procedure name of the function/procedure where it is being invoked.  It would be very convenient to make that work somehow.

So that's my question now: does anyone know a way that is acceptable to the compiler to have it feed the function/procedure name as a parameter value ?

thank you for your help.

Martin_fr:
It also fails if the "{$I %CURRENTROUTINE%}" is placed outside the class in the interface section...

And in both cases, I would ask what should it include? There can't be a current routine, outside of a routine? (not sure if the header of a routine is considered part of it for that particular directive).

Of course, it still shouldn't crash, but rather give an error....

Martin_fr:

--- Quote from: 440bx on May 20, 2024, 07:54:08 pm ---Have the "SetProcName" automatically grab the function/procedure name of the function/procedure where it is being invoked. 

--- End quote ---

I was thinking about 2nd guessing that... Because (if that code worked), I would expect it to include the name of the procedure that contains the directive. So always "SetProcName".

IIRC someone did once try that with macros, and that did not work either.

440bx:

--- Quote from: Martin_fr on May 20, 2024, 07:57:48 pm ---IIRC someone did once try that with macros, and that did not work either.

--- End quote ---
That's the kind of stuff that crosses the mind while coding and tried to see if by any chance it works (don't want to miss out on a good thing if it works.)

It was worth a try... didn't work... oh well.

but, as you said, it should emit an error not an internal exception.

Navigation

[0] Message Index

[#] Next page

Go to full version