View Issue Details

IDProjectCategoryView StatusLast Update
0035820FPCCompilerpublic2019-07-11 04:16
ReporterAkira1364Assigned To 
PriorityhighSeveritycrashReproducibilityalways
Status newResolutionopen 
Platformx86_64OSWindowsOS Version10
Product Version3.3.1Product BuildTrunk 
Target VersionFixed in Version 
Summary0035820: Any use whatsoever of "label" and "goto" in a procedure marked as inline crashes the compiler.
DescriptionI'm aware that inline would not be supported (AFAIK) for methods containing gotos in the first place, however, that's a different thing than hard-crashing the compiler (with no real error message).
Steps To ReproduceAttempt to compile the following example program:

program BugExample;

{$mode ObjFPC}
{$GOTO ON}

type SubRange = 1..3;

  procedure Blah(const I: SubRange); inline;
  var
    B: Boolean = True;
  label
    Top;
  begin
    Top:
      case I of
        1:
          WriteLn(2);
        2:
          if B then
          begin
            B := False;
            WriteLn('Resetting!');
            goto Top;
          end
          else
            WriteLn(4);
        3:
          WriteLn(6);
      end;
  end;

  procedure DoIt;
  begin
    Blah(1);
    Blah(2);
    Blah(3);
  end;

begin
  DoIt;
end.

Note that if "inline" is removed, it compiles without issues and runs as expected.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Akira1364

2019-07-10 17:37

reporter   ~0117137

Last edited: 2019-07-10 19:11

View 4 revisions

Hmm. It appears I was somewhat wrong:

In fact, inlining does not *always* crash the compiler in conjunction with label / goto, and procedures containing them *can* be successfully inlined.

For example:

  procedure Infinite; inline;
  label
    Bad;
  begin
    Bad:
      Write(1);
    goto Bad;
  end;

  procedure LoopForever;
  begin
    Infinite;
  end;

Examining the assembler output for that shows that "Infinite" is indeed fully inlined into "LoopForever".

I think the issue might actually be something to do with the specific presence of case blocks, as existed in my main example of the bug.

Serge Anvarov

2019-07-11 00:46

reporter   ~0117151

My compiler doesn't crash, but eats up memory until I kill it. FPC 3.0.4 and FPC 3.1.1, both x64. Windows 7.

Issue History

Date Modified Username Field Change
2019-07-10 17:11 Akira1364 New Issue
2019-07-10 17:37 Akira1364 Note Added: 0117137
2019-07-10 17:39 Akira1364 Note Edited: 0117137 View Revisions
2019-07-10 17:39 Akira1364 Note Edited: 0117137 View Revisions
2019-07-10 19:11 Akira1364 Note Edited: 0117137 View Revisions
2019-07-11 00:46 Serge Anvarov Note Added: 0117151
2019-07-11 04:15 J. Gareth Moreton Priority normal => high
2019-07-11 04:15 J. Gareth Moreton Severity minor => crash
2019-07-11 04:15 J. Gareth Moreton FPCTarget => -