Type helpers class function overloading causes A/V in compiler
Original Reporter info from Mantis: pda
-
Reporter name: Dmitriy Pomerantsev
Original Reporter info from Mantis: pda
- Reporter name: Dmitriy Pomerantsev
Description:
When I'm trying to compile program with class function overloading (in both objfpc and delphiunicode mode, both in x86 and x86_64 compiler) I getting only such error:
Fatal: Compilation aborted
An unhandled exception occurred at $0044D6E6:
EAccessViolation: Access violation
$0044D6E6
$004C49E0
$004C4204
$0048BF73
$00441867
$004DB83F
$004DB496
$004DC2D8
$004DE12A
$004DE15B
$004DE15B
$004DE15B
$004DEBB6
$0050FA12
$0050FDF7
$004F240C
$0053C225
Steps to reproduce:
Just compile this code:
program test;
{$MODE DELPHIUNICODE}{$H+}
{$MODESWITCH TYPEHELPERS}
uses
sysutils;
type
TStringHelper = record helper for UnicodeString
public
class function Cr(AStr: UnicodeString): UnicodeString; static; overload;
end;
class function TStringHelper.Cr(AStr: UnicodeString): UnicodeString;
begin
Result := '#'+AStr;
end;
var
us: UnicodeString;
begin
us := UnicodeString.Cr('a');
writeln(us);
end.
or:
program test;
{$MODE OBJFPC}{$H+}
{$MODESWITCH TYPEHELPERS}
uses
sysutils;
type
TStringHelper = type helper for UnicodeString
class function Cr(AStr: UnicodeString): UnicodeString; static; overload;
end;
class function TStringHelper.Cr(AStr: UnicodeString): UnicodeString;
begin
Result := '#'+AStr;
end;
var
us: UnicodeString;
begin
us := UnicodeString.Cr('a');
writeln(us);
end.
Mantis conversion info:
- Mantis ID: 26615
- OS: Windows
- OS Build: Windows 7
- Build: #28465
- Platform: Windows
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 28572 (#244ac127)