View Issue Details

IDProjectCategoryView StatusLast Update
0036554FPCCompilerpublic2020-01-11 22:53
ReporterMarģersAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Platformx86_64OSlinuxOS Version.
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0036554: internal error 200611054 (for loop with no ordinal type)
Description
example code throws 2 errors
1) Error : Ordinal expression expected (Ok)
2) Fatal: Internal error 200611054 (not Ok)
Steps To Reproducetype oWord = record q1,q2 : qword; end;

procedure megadoodoo;
var a : oWord;

begin
     for a:=0 to 3 do
     begin
     end;
end;
Tagsinternal error
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files
  • i36554.patch (1,477 bytes)
    Index: compiler/pstatmnt.pas
    ===================================================================
    --- compiler/pstatmnt.pas	(revision 43909)
    +++ compiler/pstatmnt.pas	(working copy)
    @@ -370,7 +370,7 @@
                  hp,
                  hblock,
                  hto,hfrom : tnode;
    -             backward : boolean;
    +             backward, loopvarbad : boolean;
                  loopvarsym : tabstractvarsym;
               begin
                  { Check loop variable }
    @@ -385,7 +385,12 @@
                    ) and
                    (hloopvar.resultdef.typ<>undefineddef)
                    then
    -               MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
    +                 begin
    +                   MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
    +                   loopvarbad := True;
    +                 end
    +               else
    +                 loopvarbad := False;
     
                  hp:=hloopvar;
                  while assigned(hp) and
    @@ -478,8 +483,11 @@
                  consume(_DO);
     
                  { Check if the constants fit in the range }
    -             check_range(hfrom,hloopvar.resultdef);
    -             check_range(hto,hloopvar.resultdef);
    +             if not loopvarbad then
    +               begin
    +                 check_range(hfrom,hloopvar.resultdef);
    +                 check_range(hto,hloopvar.resultdef);
    +               end;
     
                  { first set the varstate for from and to, so
                    uses of loopvar in those expressions will also
    
    i36554.patch (1,477 bytes)

Activities

J. Gareth Moreton

2020-01-11 17:30

developer   ~0120333

Confirmed in trunk on x86_64-win64.

Internal Error 200611054 is raised when getrange is called for an invalid def.type (in this case, recorddef).

I'll do some looking around to see if this is an easy fix or requires a bit more thought.

J. Gareth Moreton

2020-01-11 17:44

developer  

i36554.patch (1,477 bytes)
Index: compiler/pstatmnt.pas
===================================================================
--- compiler/pstatmnt.pas	(revision 43909)
+++ compiler/pstatmnt.pas	(working copy)
@@ -370,7 +370,7 @@
              hp,
              hblock,
              hto,hfrom : tnode;
-             backward : boolean;
+             backward, loopvarbad : boolean;
              loopvarsym : tabstractvarsym;
           begin
              { Check loop variable }
@@ -385,7 +385,12 @@
                ) and
                (hloopvar.resultdef.typ<>undefineddef)
                then
-               MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
+                 begin
+                   MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
+                   loopvarbad := True;
+                 end
+               else
+                 loopvarbad := False;
 
              hp:=hloopvar;
              while assigned(hp) and
@@ -478,8 +483,11 @@
              consume(_DO);
 
              { Check if the constants fit in the range }
-             check_range(hfrom,hloopvar.resultdef);
-             check_range(hto,hloopvar.resultdef);
+             if not loopvarbad then
+               begin
+                 check_range(hfrom,hloopvar.resultdef);
+                 check_range(hto,hloopvar.resultdef);
+               end;
 
              { first set the varstate for from and to, so
                uses of loopvar in those expressions will also
i36554.patch (1,477 bytes)

J. Gareth Moreton

2020-01-11 17:44

developer   ~0120334

Can you confirm that this patch fixes the problem?

Marģers

2020-01-11 19:34

reporter   ~0120337

Patch fixes problem with internal error.

J. Gareth Moreton

2020-01-11 20:27

developer   ~0120339

Assigned to Florian for patch verification.

Florian

2020-01-11 22:15

administrator   ~0120340

I used a more general approach.

Marģers

2020-01-11 22:53

reporter   ~0120343

Thanks

Issue History

Date Modified Username Field Change
2020-01-11 16:46 Marģers New Issue
2020-01-11 17:30 J. Gareth Moreton Assigned To => J. Gareth Moreton
2020-01-11 17:30 J. Gareth Moreton Status new => confirmed
2020-01-11 17:30 J. Gareth Moreton FPCTarget => -
2020-01-11 17:30 J. Gareth Moreton Note Added: 0120333
2020-01-11 17:44 J. Gareth Moreton File Added: i36554.patch
2020-01-11 17:44 J. Gareth Moreton Assigned To J. Gareth Moreton =>
2020-01-11 17:44 J. Gareth Moreton Status confirmed => feedback
2020-01-11 17:44 J. Gareth Moreton Note Added: 0120334
2020-01-11 19:34 Marģers Note Added: 0120337
2020-01-11 19:34 Marģers Status feedback => new
2020-01-11 20:26 J. Gareth Moreton Tag Attached: internal error
2020-01-11 20:26 J. Gareth Moreton Assigned To => Florian
2020-01-11 20:26 J. Gareth Moreton Status new => assigned
2020-01-11 20:27 J. Gareth Moreton Status assigned => feedback
2020-01-11 20:27 J. Gareth Moreton Note Added: 0120339
2020-01-11 22:15 Florian Status feedback => resolved
2020-01-11 22:15 Florian Resolution open => fixed
2020-01-11 22:15 Florian Fixed in Version => 3.3.1
2020-01-11 22:15 Florian Note Added: 0120340
2020-01-11 22:53 Marģers Status resolved => closed
2020-01-11 22:53 Marģers Note Added: 0120343