The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,740 other followers

Archive for October 5th, 2016

In `System.SysUtils`, `class function TCardinalHelper.Parse` throws errors for valid Cardinal values

Posted by jpluimers on 2016/10/05

Oh nice System.SysUtils.TCardinalHelper.Parse:

class function TCardinalHelper.Parse(const S: string): Cardinal;
begin
  Result := StrToInt(S);
end;

Which means you get this nice EConvertError with message ''4294967295' is not a valid integer value'. with this simple test (which doesn’t even reach the Assert):

uses
  System.SysUtils;

procedure Cardinal_Parse_High_Cardinal_Succeeds();
var
  Expected: Cardinal;
  Value: string;
  Actual: Cardinal;
begin
  Expected := High(Cardinal);
  Value := Expected.ToString();
  Actual := Cardinal.Parse(Value);
  Assert(Expected = Actual);
end;

So I write some unit tests (see below) of which helpers for these types fail in one way or the other:

  • Cardinal
  • NativeUInt
  • Single
  • Double
  • Extended

These work for the boundary cases:

  • SmallInt
  • ShortInt
  • Integer
  • Int64
  • NativeInt
  • Byte
  • Word
  • UInt64
  • Boolean
  • ByteBool
  • WordBool
  • LongBool

 

–jeroen

via: Oh nice, in System.SysUtils: “` class function TCardinalHelper.Parse(const…

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 5 Comments »

Happy 25th birthday Linux!

Posted by jpluimers on 2016/10/05

Linux turns 25 today: Linux – Wikipedia, the free encyclopedia

Happy birthday!

–jeroen

Posted in *nix, Linux, Power User | Leave a Comment »

TMemIniFile have non-virtual SetStrings procedure. To add support processing of…

Posted by jpluimers on 2016/10/05

TMemIniFile have non-virtual SetStrings procedure.

One of the classic Delphi RTL examples of Delphi team members  not reading Delphi Component Design by +Danny Thorpe 

You can still get it for a few dollars, used: http://www.amazon.com/Delphi-Component-Design-Danny-Thorpe/dp/0201461366

–jeroen

via: TMemIniFile have non-virtual SetStrings procedure. To add support processing of….

Posted in Delphi, Development, Software Development | 1 Comment »

Delphi XE8 [dcc32 Fatal Error] dcc32_F2084_C2359.dpr(30): F2084 Internal Error: C2359

Posted by jpluimers on 2016/10/05

Fails in Delphi XE8 with a nice [dcc32 Fatal Error] dcc32_F2084_C2359.dpr(27): F2084 Internal Error: C2359

It is fixed in Delphi 10.0 Berlin, but of course a C2359 search does not reveal that as Quality Portal is behind a wall. So for future reference the bug: [RSP-13471] Int64 for loops can generate Internal Compiler Error – Embarcadero Technologies. Thanks +Stefan Glienke for mentioning the issue.

program dcc32_F2084_C2359;

type
  TNumber = Int64; // UInt64; // fails too; other numeric types do not fail. Fails in a unit as well.
  TNumbers = TArray;
  TNumberRange = record
  strict private
    function GetLowerBound: TNumber;
  public
    function Numbers: TNumbers;
    property LowerBound: TNumber read GetLowerBound;
  end;

{ TNumberRange }

function TNumberRange.GetLowerBound: TNumber;
begin
  Result := Default(TNumber);
end;

function TNumberRange.Numbers: TNumbers;
var
  lValue: TNumber;
begin
  for lValue := LowerBound to LowerBound do
  ;
end;

begin
end.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi XE8, Development, F2084, Software Development | 1 Comment »

 
%d bloggers like this: