Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/RTTI    [ Add a report in this area ]  
Report #:  96343   Status: Open
Missing TValue class operators
Project:  Delphi Build #:  16.0.4203.41037
Version:    16.0 Submitted By:   Stefan Glienke
Report Type:  Basic functionality failure Date Reported:  7/18/2011 5:24:08 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   284997
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 16
Description
There are some class operator overloads missing for TValue which results in non expected behaviour. In the example project there are several unexpected types displayed.

It gets worse, when you compile it for 64bit because then the results for NativeInt and NativeUInt change.
Steps to Reproduce:
program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.Rtti,
  System.SysUtils;

var
  v: TValue;
begin
  try
    v := NativeInt(High(NativeInt));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString);

    v := NativeUInt(High(NativeUInt));
    Writeln(v.TypeInfo.Name); // expected: Cardinal, actual: Int64
    Writeln(v.ToString);

    v := Integer(High(Integer));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString);

    v := Cardinal(High(Cardinal));
    Writeln(v.TypeInfo.Name); // expected: Cardinal, actual: Int64
    Writeln(v.ToString);

    v := Int64(High(Int64));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString);

    v := UInt64(High(UInt64));
    Writeln(v.TypeInfo.Name); // expected: UInt64, actual: Extended
    Writeln(v.ToString);

    v := TValue.From<NativeUInt>(High(NativeUInt));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString); // expected: 4294967295, actual: -1

    v := TValue.From<Cardinal>(High(Cardinal));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString); // expected: 4294967295, actual: -1

    v := TValue.From<UInt64>(High(UInt64));
    Writeln(v.TypeInfo.Name);
    Writeln(v.ToString);

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;
end.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01