Use of Default in generic record with specialization for itself generates unresolved symbol reference with debug symbols enabled

Summary

A generic record TFoo<T> that contains code that calls Default with a specialization for itself (e.g. Default(specialize TFoo<T>)) generates unresolved symbol reference when compiling with debug symbols enabled.

System Information

  • Operating system: Linux
  • Processor architecture: x86-64
  • Compiler version: trunk c09e8778
  • Device: Computer

Steps to reproduce

Try to compile the program below

Example Project

program Test;
{$mode objfpc}{$H+}{$modeswitch advancedrecords}
type
  generic TFoo<T> = record
  public
    // Note: the issue exists even with "procedure ..."
    class operator Initialize(var AFoo: specialize TFoo<T>);
  end;

class operator TFoo.Initialize(var AFoo: specialize TFoo<T>);
begin
  AFoo:=Default(specialize TFoo<T>);
end;

begin
end.

Compile with fpc -g test.pas.

What is the current bug behavior?

Trying to compile the code above results with the error /usr/bin/ld.bfd: test.o:(.debug_info+0x74): undefined reference to `_$TEST$_Ld1'.

What is the expected (correct) behavior?

Compile and link should work properly.

Note that this is a recent regression as FPC trunk from a few of months ago worked fine. FPC 3.2.2 also compiles this code fine when debug symbols are enabled.

Assignee Loading
Time tracking Loading