View Issue Details

IDProjectCategoryView StatusLast Update
0037423FPCCompilerpublic2020-08-08 21:56
ReporterNikolay Nikolov Assigned ToJonas Maebe  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037423: inline bug
DescriptionThe following linker error is produced, when compiling the attached program. Problem disappears when inlining is turned off ({$INLINE OFF}). This was tested on x86_64-linux, using Fedora 32.

Free Pascal Compiler version 3.2.0 [2020/06/21] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling inline_bug.pas
Linking inline_bug
/usr/bin/ld: inline_bug.o: in function `P$INLINE_BUG$_$TMODULE_$__$$_DOSTUFF':
inline_bug.pas:(.text.n_p$inline_bug$_$tmodule_$__$$_dostuff+0x59): undefined reference to `.Lj62'
inline_bug.pas(69,1) Error: Error while linking
inline_bug.pas(69,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Steps To ReproduceSee Description.
Additional InformationProblem exists in FPC 3.2.0 and FPC 3.2.1 from the current fixes_3_2 branch. FPC trunk doesn't seem to be affected (or this might already be fixed there already).
TagsNo tags attached.
Fixed in Revision46334
FPCOldBugId
FPCTarget-
Attached Files

Relationships

has duplicate 0037496 resolvedJonas Maebe Incorrect "Undefined symbol" for unit's private function with public inlined overloaded versions 

Activities

Nikolay Nikolov

2020-07-27 04:03

developer  

inline_bug.pas (1,926 bytes)   
program inline_bug;

{$MODE objfpc}

{ bug is only triggered when inlining is on }
{$INLINE on}

{

[nickysn@dhcppc1 inline_bug]$ fpc inline_bug
Free Pascal Compiler version 3.2.0 [2020/06/21] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling inline_bug.pas
Linking inline_bug
/usr/bin/ld: inline_bug.o: in function `P$INLINE_BUG$_$TMODULE_$__$$_DOSTUFF':
inline_bug.pas:(.text.n_p$inline_bug$_$tmodule_$__$$_dostuff+0x59): undefined reference to `.Lj62'
inline_bug.pas(69,1) Error: Error while linking
inline_bug.pas(69,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

}

type
  TSample = class
  private
    function GetContainsData: Boolean; inline;
  public
    property ContainsData: Boolean read GetContainsData;
  end;
  TSampleList = class
  private
    FSampleList: array [1..10] of TSample;
    function GetSample(Index: Integer): TSample; inline;
  public
    constructor Create;
    property Sample[Index: Integer]: TSample read GetSample; default;
  end;
  TModule = class
  private
    FSamples: TSampleList;
  public
    constructor Create;
    procedure DoStuff;
  end;

function TSample.GetContainsData: Boolean; inline;
begin
  Result := False;
end;

constructor TSampleList.Create;
var
  I: Integer;
begin
  for I := 1 to 10 do
    FSampleList[I] := TSample.Create;
end;

function TSampleList.GetSample(Index: Integer): TSample; inline;
begin
  if (Index < Low(FSampleList)) or (Index > High(FSampleList)) then
    raise TObject.Create;
  Result := FSampleList[Index];
end;

constructor TModule.Create;
begin
  FSamples := TSampleList.Create;
end;

procedure TModule.DoStuff;
var
  I: Integer;
begin
  for I := 1 to 10 do
    if FSamples[I].ContainsData then
      Writeln('!!!');
end;

var
  Module: TModule;
begin
  Module := TModule.Create;
  Module.DoStuff;
end.
inline_bug.pas (1,926 bytes)   

Jonas Maebe

2020-08-08 19:46

manager   ~0124676

Last edited: 2020-08-08 19:46

View 2 revisions

This bug is already fixed in trunk, but I don't know by which revision. I added your test program.

Issue History

Date Modified Username Field Change
2020-07-27 04:03 Nikolay Nikolov New Issue
2020-07-27 04:03 Nikolay Nikolov File Added: inline_bug.pas
2020-08-08 19:46 Jonas Maebe Assigned To => Jonas Maebe
2020-08-08 19:46 Jonas Maebe Status new => resolved
2020-08-08 19:46 Jonas Maebe Resolution open => fixed
2020-08-08 19:46 Jonas Maebe Fixed in Version => 3.3.1
2020-08-08 19:46 Jonas Maebe Fixed in Revision => 46334
2020-08-08 19:46 Jonas Maebe FPCTarget => -
2020-08-08 19:46 Jonas Maebe Note Added: 0124676
2020-08-08 19:46 Jonas Maebe Note Edited: 0124676 View Revisions
2020-08-08 21:56 Jonas Maebe Relationship added has duplicate 0037496