View Issue Details

IDProjectCategoryView StatusLast Update
0036446FPCCompilerpublic2020-03-15 10:58
Reporteravk Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformx86, x86_64OSWindows, Linux 
Product Version3.3.1 
Summary0036446: Compiler crashes on a generic record with an anonymous record field.
DescriptionThe compiler crashes on "EAccessViolation: Access violation" exception when generic record type contains an anonymous record field:

Hint: (11030) Start of reading config file .../fpc/bin/x86_64-linux/fpc.cfg
Hint: (11031) End of reading config file .../fpc/bin/x86_64-linux/fpc.cfg
An unhandled exception occurred at $00000000004DF059:
EAccessViolation: Access violation
  $00000000004DF059

Free Pascal Compiler version 3.3.1-r43687 [2019/12/15] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling test.lpr
.../test.lpr(42,4) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
Error: .../fpc/bin/x86_64-linux/ppcx64 returned an error exitcode

An example reproducing the error is attached.
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

avk

2019-12-16 06:51

reporter  

test.pas (686 bytes)   
program test;
{$mode objfpc}
{$modeswitch advancedrecords}
type
  generic TElement<T> = record
    DeletedAt, SwapedAt: Integer;
    Origin: record
      Value: T;
      Index: Integer;
    end;
  end;

  generic TNode<T> = record
  var
    Next: ^TNode;
    Previous: ^TNode;
    Data: array of specialize TElement<T>;
  end;

  generic TDoublyLinkedArray<T> = class
  type
    TSpecNode = specialize TNode<T>;
    PNode = ^TSpecNode;
  private
    FCurrent,
    FNext: PNode;
  public
    constructor Create;
  end;

constructor TDoublyLinkedArray.Create;
begin
  inherited;
end;

var
  List: specialize TDoublyLinkedArray<Byte>;

begin

end.
test.pas (686 bytes)   

creaothceann

2020-03-14 12:46

reporter   ~0121605

Also happens without using generics, please remove tag if possible...

{$ModeSwitch AdvancedRecords}

type r = record
    type w = word;
    var case integer of
        0: (a : byte);
        1: (b : byte);
end;

After this type declaration, invoking identifier completion (Lazarus default: CTRL+SPACE) creates error "Case only allowed in records" and puts the text cursor on the "case".

Tested with https://sourceforge.net/projects/lazarus-snapshots/files/Window%2064/lazarus-2.0.6-62131-fpc-3.2.0-beta-43271/
test2.pas (173 bytes)   
unit test;


{$ModeSwitch AdvancedRecords}


interface


type r = record
	type w = word;
	var case integer of
		0: (a : byte);
		1: (b : byte);
end;


implementation


end.
test2.pas (173 bytes)   
version.png (105,092 bytes)   
version.png (105,092 bytes)   

Bart Broersma

2020-03-14 15:28

reporter   ~0121607

@creaothceann
> Also happens without using generics
Do you mean that the compiler crashes on this?
Because that is what this bugreport is about.

I tested that piece of code with fpc r44297 and it compiles just fine.

CodeTools is part of Lazarus.
If it chokes on such a declaration, and the compiler allows it, then file a separate bugreport about CodeTools in the Lazarus section of the bugtracker please.

Bart Broersma

2020-03-14 15:30

reporter   ~0121608

Last edited: 2020-03-14 16:27

View 2 revisions

I can confirm the original sample code crashes the compiler (r44297 32-bit on Win10-64).

test.pas(41,4) Error: Compilation raised exception internally
Fatal: Compilation aborted
An unhandled exception occurred at $004A4106:
EAccessViolation: Access violation
  $004A4106 PROCESS_ABSTRACTRECORDDEF, line 1655 of pgenutil.pas
  $00439D91 COMPILE, line 409 of parser.pas
  $004165DD COMPILE, line 278 of compiler.pas

creaothceann

2020-03-14 15:42

reporter   ~0121609

You're right, it compiles fine. I was following the link from here: https://forum.lazarus.freepascal.org/index.php/topic,47687.msg342986.html#msg342986

creaothceann

2020-03-15 10:58

reporter   ~0121616

> If it chokes on such a declaration, and the compiler allows it, then file a separate bugreport about CodeTools in the Lazarus section

Done: https://bugs.freepascal.org/view.php?id=36795

Issue History

Date Modified Username Field Change
2019-12-16 06:51 avk New Issue
2019-12-16 06:51 avk File Added: test.pas
2019-12-16 06:52 avk Tag Attached: generics
2020-03-14 12:46 creaothceann File Added: test2.pas
2020-03-14 12:46 creaothceann File Added: version.png
2020-03-14 12:46 creaothceann Note Added: 0121605
2020-03-14 15:28 Bart Broersma Note Added: 0121607
2020-03-14 15:30 Bart Broersma Note Added: 0121608
2020-03-14 15:42 creaothceann Note Added: 0121609
2020-03-14 16:27 Bart Broersma Note Edited: 0121608 View Revisions
2020-03-15 10:58 creaothceann Note Added: 0121616