Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  121517   Status: Closed
URW1154 when using a typed boolean constant inside of a generic class
Project:  Delphi Build #:  19.0.14356.6604
Version:    19.0 Submitted By:   Sebastian Jaenicke
Report Type:  Crash / Data loss / Total failure Date Reported:  1/3/2014 6:06:24 AM
Severity:    Critical / Show Stopper Last Updated: 4/15/2014 6:33:55 PM
Platform:    All platforms Internal Tracking #:   46394
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 20
Description
The internal error URW1154 is raised when compiling for Windows (32-Bit or 64-Bit) if you:
- declare a class with a generic parameter in unit A
- declare a typed constant of type Boolean inside of the class (it does not matter whether it is a field or a local constant inside a method)
- use this constant in a method of the class
- declare a class derived of this class in unit B and specify a specific type for the generic parameter
- add the two units to a project (it does not matter which type, testet with VCL forms and command line)
- try to compile it

If you compile for Android you get this error instead:
[DCC Fehler] ChildClass.pas(16): E2581 Backend-Fehler: invalid linkage type for global declaration
%6* @_ZZN9Baseclass13TBaseClass__1IN6System12DelphiObjectINS1_7TObjectEEEE7doStuffEvE12someConstant
Broken module found, compilation terminated.

So it tells you at least where the error comes from. (The internal error gives no hint where the problem occurs.)
Steps to Reproduce:
1. Open the attached project
-----------
program URW1154Test;
{$APPTYPE CONSOLE}
{$R *.res}
uses
  System.SysUtils,
  BaseClass in 'BaseClass.pas',
  ChildClass in 'ChildClass.pas';
begin
  try
    { TODO -oUser -cConsole Main : Code hier einf·en }
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
-----------
-----------
unit BaseClass;
interface
uses SysUtils;

type
  TBaseClass<T> = class
  public
    procedure doStuff();
  end;

implementation

procedure TBaseClass<T>.doStuff();
const
  someConstant: Boolean = True;
begin
  BoolToStr(someConstant);
end;

end.
-----------
-----------
unit ChildClass;
interface

uses BaseClass;

type
  TChildClass = class(TBaseClass<TObject>);

implementation
end.
-----------

2. Try to compile it for any of the platforms

Expected:
Compiles without errors

Actual:
- When compiling for Windows: internal error URW1154
- When compiling for Android: E2581 Backend-Fehler: invalid linkage type for global declaration
%6* @_ZZN9Baseclass13TBaseClass__1IN6System12DelphiObjectINS1_7TObjectEEEE7doStuffEvE12someConstant
Broken module found, compilation terminated.
Workarounds
- declare the derived class within the same unit
- OR make the typed constant global (declare it outside of the class)
- OR use a normal constant instead of a typed constant
Attachment
URW1154 Error Test.zip
Comments

None

Server Response from: ETNACODE01