View Issue Details

IDProjectCategoryView StatusLast Update
0031714FPCCompilerpublic2020-07-26 13:07
ReporterNitorami Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformPCOSXP, Windows 7 
Product Version3.0.2 
Summary0031714: Compiler: Access Violation on inlined procedure using a local goto instruction
DescriptionThe compiler crashes on inlined procedure using a local goto instruction. Both 3.0.0 and 3.0.2.
Steps To ReproduceCompile the attached example using

fpc -Si -Sg crashme.pas

or from the IDE.

Enabling goto may not even be required, the compiler will then issue an error "GOTO and LABEL not supported" before it crashes.
Additional Information- WARNING: The compiler tries to allocate large amounts of memory which may choke older PCs.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Relationships

duplicate of 0035820 resolvedFlorian Any use whatsoever of "label" and "goto" in a procedure marked as inline crashes the compiler. 
related to 0037420 resolvedFlorian [Patch] Fix for incorrect alignment removal 

Activities

Nitorami

2017-04-25 17:50

reporter  

crashme.pas (283 bytes)

Thaddy de Koning

2017-04-25 18:28

reporter   ~0099931

Last edited: 2017-04-25 18:34

View 4 revisions

Hm. Are you serious?
You declare a label and never use it?
Of course this is a bug (jumping to a declaration) , but it is also wrong code (expecting it to jump there...)

E.g:
var
  i : Integer;

label
  GotoLabel;

begin
  for i := 1 to 10 do
  begin
    ShowMessage('i = '+IntToStr(i));

    if i = 4 then Goto GotoLabel; // Conditionally exit the loop
  end;

  ShowMessage('The loop finished OK');
GotoLabel:
  ShowMessage('Loop finished with i = '+IntToStr(i));
end;

Source: http://www.delphibasics.co.uk/RTL.asp?Name=Goto

I am not quite sure if you filed the bug because of.... But it's a bug anyway.

Serge Anvarov

2017-04-25 18:49

reporter   ~0099934

If you add ';' after the label then the program compiles without errors. But in pascal language there are no requirements to separate the label from the subsequent operator.

Serge Anvarov

2017-04-25 18:52

reporter   ~0099935

Thaddy, look at the code carefully. The label is, and it is earlier than goto.

Nitorami

2017-04-25 21:01

reporter   ~0099936

In real life I would use a while loop of course. But other than that, the code should be correct - at least I don't see where it is not. Yes, the label appears earlier than goto, but I am not aware that this is forbidden.

Without the inline modifier, it compiles ok and prints the correct result: 100. The problem only appears when inlining the procedure.

Thaddy de Koning

2017-05-03 15:45

reporter   ~0100080

Yes. Seems to be serious. Re-tested and confirmed.

Bi0T1N

2020-07-25 22:13

reporter   ~0124331

Last edited: 2020-07-25 22:28

View 2 revisions

Issue can be marked as resolved. Program compiles w/o errors (3.3.1-r45857).

Florian

2020-07-25 23:09

administrator   ~0124335

I added the test at least.

Issue History

Date Modified Username Field Change
2017-04-25 17:50 Nitorami New Issue
2017-04-25 17:50 Nitorami File Added: crashme.pas
2017-04-25 18:28 Thaddy de Koning Note Added: 0099931
2017-04-25 18:31 Thaddy de Koning Note Edited: 0099931 View Revisions
2017-04-25 18:31 Thaddy de Koning Note Edited: 0099931 View Revisions
2017-04-25 18:34 Thaddy de Koning Note Edited: 0099931 View Revisions
2017-04-25 18:49 Serge Anvarov Note Added: 0099934
2017-04-25 18:52 Serge Anvarov Note Added: 0099935
2017-04-25 21:01 Nitorami Note Added: 0099936
2017-05-03 15:45 Thaddy de Koning Note Added: 0100080
2020-07-25 22:13 Bi0T1N Note Added: 0124331
2020-07-25 22:28 Bi0T1N Note Edited: 0124331 View Revisions
2020-07-25 23:09 Florian Assigned To => Florian
2020-07-25 23:09 Florian Status new => resolved
2020-07-25 23:09 Florian Resolution open => no change required
2020-07-25 23:09 Florian FPCTarget => -
2020-07-25 23:09 Florian Note Added: 0124335
2020-07-26 12:47 J. Gareth Moreton Relationship added related to 0037420
2020-07-26 13:07 Jonas Maebe Relationship added duplicate of 0035820