View Issue Details

IDProjectCategoryView StatusLast Update
0032179FPCCompilerpublic2019-05-23 20:40
ReporterMaciej IzakAssigned ToJonas Maebe 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version3.1.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0032179: Wrong priority for string for overloaded methods
DescriptionFPC prefers to call Create with untyped Data instead of version with string (also Delphi incompatible):

{$mode delphi}

type
  TGuidHelper = record helper for TGUID
    Class Function Create(const Data): TGUID; overload; static; inline;
    Class Function Create(const S: string): TGUID; overload; static;
  end;

class function TGuidHelper.Create(const Data): TGUID;
begin
  writeln('A');
end;

class function TGuidHelper.Create(const S: string): TGUID;
begin
  writeln('B');
end;

var
  c: PChar;
  g: TGUID;
begin
  g.Create(utf8string(c)); // will print 'A'
  g.Create(unicodestring(c)); // will print 'A'
  g.Create(shortstring(c)); // will print 'A'
end.
TagsNo tags attached.
Fixed in Revision40012
FPCOldBugId0
FPCTarget
Attached Files

Relationships

related to 0035576 closedMichael Van Canneyt r42042-r42049 prevent Lazarus (i386) from starting 

Activities

Thaddy de Koning

2017-07-20 18:02

reporter   ~0101823

Last edited: 2017-07-20 18:05

View 3 revisions

Delphi has the documented premise it eliminates empty procs as optmization.
FPC does the same (in -O2+)
What I see here is merely a Delphi bug...
Do you suggest FPC should mimic every Delphi bug?...

Thaddy de Koning

2017-07-20 18:02

reporter   ~0101824

Last edited: 2017-07-20 18:06

View 2 revisions

'Oh, yes'?

In this case you didn't even look at the generated code...

Maciej Izak

2017-07-21 11:10

reporter   ~0101834

Optimization is not mentioned in this bug report. You missed the point. Anyway example is now corrected. In presented example FPC should call "Create(const S: string)" instead of "Create(const Data)".

Thaddy de Koning

2017-07-21 13:42

reporter   ~0101837

Last edited: 2017-07-21 13:48

View 5 revisions

I did not miss the point: It is a bug if it chooses - an implementation, not empty - the untyped version first. The compiler should be able to check for typed versions first, before falling back to an untyped const. If that is what you mean it is a bug at least in my opinion too..

I merely made you look at the actual output...(which removes the empty proc)
I can confirm this is the case, and can imho not be contributed to implementation detail.

Maciej Izak

2017-07-21 13:48

reporter   ~0101838

Exactly.

Issue History

Date Modified Username Field Change
2017-07-20 15:46 Maciej Izak New Issue
2017-07-20 18:02 Thaddy de Koning Note Added: 0101823
2017-07-20 18:02 Thaddy de Koning Note Added: 0101824
2017-07-20 18:03 Thaddy de Koning Note Edited: 0101823 View Revisions
2017-07-20 18:05 Thaddy de Koning Note Edited: 0101823 View Revisions
2017-07-20 18:06 Thaddy de Koning Note Edited: 0101824 View Revisions
2017-07-21 11:07 Maciej Izak Description Updated View Revisions
2017-07-21 11:10 Maciej Izak Note Added: 0101834
2017-07-21 13:42 Thaddy de Koning Note Added: 0101837
2017-07-21 13:43 Thaddy de Koning Note Edited: 0101837 View Revisions
2017-07-21 13:44 Thaddy de Koning Note Edited: 0101837 View Revisions
2017-07-21 13:47 Thaddy de Koning Note Edited: 0101837 View Revisions
2017-07-21 13:48 Maciej Izak Note Added: 0101838
2017-07-21 13:48 Thaddy de Koning Note Edited: 0101837 View Revisions
2018-10-21 23:03 Jonas Maebe Fixed in Revision => 40012
2018-10-21 23:03 Jonas Maebe Status new => resolved
2018-10-21 23:03 Jonas Maebe Fixed in Version => 3.3.1
2018-10-21 23:03 Jonas Maebe Resolution open => fixed
2018-10-21 23:03 Jonas Maebe Assigned To => Jonas Maebe
2019-05-23 20:40 Jonas Maebe Relationship added related to 0035576