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,854 other subscribers

Archive for the ‘Delphi’ Category

David Heffernan was on a bug reporting spree. Compiler unit tests could have detected these much faster.

Posted by jpluimers on 2018/04/12

For my archive, most bugs around UInt64 handling, lots of them in the Windows x64 compiler, all by David Heffernan:

  1. [WayBack] Who can guess what value is returned by StrToFloat(‘߀’) if the PUREPASCAL version of StrToFloat is used ……. Make sure that you copy and paste the… – David Heffernan – Google+
  2. [WayBack] Another day, another bug. This one a rather nasty one in the x64 compiler. Consider this program: {$APPTYPE CONSOLE} uses System.SysUtils; var … – David Heffernan – Google+
  3. And my run of bugs continues: https://quality.embarcadero.com/browse/RSP-20351 This program: {$APPTYPE CONSOLE} var D: Double; U64: UInt64; begin … – David Heffernan – Google+
  4. [WayBack] Final bug of my day: https://quality.embarcadero.com/browse/RSP-20353 {$APPTYPE CONSOLE} var I: Integer; U64: UInt64; D: Double; begin I := 1;… – David Heffernan – Google+

I also learned that quite a while ago, [Archive.is] System.TFloatSpecial – XE2 API Documentation got introduced.

1: Who can guess what value is returned by

StrToFloat('߀')

if the PUREPASCAL version of StrToFloat is used …….

Make sure that you copy and paste the code above rather than re-typing it.

To spoil the surprise read this: https://stackoverflow.com/a/49736812/

2: Another day, another bug. This one a rather nasty one in the x64 compiler.

Consider this program:

{$APPTYPE CONSOLE}

uses
  System.SysUtils;

var
  D: Double;
begin
  Writeln(fsZero=D.SpecialType);
  Writeln(fsNZero=D.SpecialType);
  D := -D;
  Writeln(fsZero=D.SpecialType);
  Writeln(fsNZero=D.SpecialType);
Readln;
end.

It should output

TRUE
FALSE
FALSE
TRUE

It does so on x86. On x64 it outputs

TRUE
FALSE
TRUE
FALSE

The reason being that Emba implemented floating point negation on x64 by compiling

-d

as

0 - d

Which is a different thing.

The right thing to do is to load the value into an XMM register, and then xor it with 8000000000000000h.

https://quality.embarcadero.com/browse/RSP-20350

That’s three bugs in two days!

3: And my run of bugs continues: https://quality.embarcadero.com/browse/RSP-20351

This program:

{$APPTYPE CONSOLE}
var
  D: Double;
  U64: UInt64;
begin
  D := high(UInt64);
  Writeln(D);

  U64 := high(UInt64);
  D := U64;
  Writeln(D);

  Readln;
end.

should output

1.84467440737096E+0019
1.84467440737096E+0019

but in fact outputs

-1.00000000000000E+0000
1.84467440737096E+0019

I guess the compiler generates code as if the constant value was treated as a signed Int64.

Shout out to +Stefan Glienke for bringing this one to my attention.

I have one more bug that I have seen, but not yet submitted.

Quite amazing what can be found with a little bit of effort. Imagine if the Emba team put in some serious testing effort?

4. Final bug of my day: https://quality.embarcadero.com/browse/RSP-20353

{$APPTYPE CONSOLE}
var
I: Integer;
U64: UInt64;
D: Double;
begin
I := 1;
U64 := $8000000000000000;
D := I * U64;
Writeln(D);

U64 := $7fffffffffffffff;
D := I * U64;
Writeln(D);

Readln;
end.

Under dcc32 all is well, the output is

9.22337203685478E+0018
9.22337203685478E+0018

but under dcc64 it all goes south

-9.22337203685478E+0018
9.22337203685478E+0018

Looks like the compiler authors still haven’t found all the parts of the code that treat UInt64 as though it were Int64.

All these bugs (5 reports, but more bugs) from one simple SO question yesterday about StrToFloat……..

Posted in Delphi, Development, Software Development | 2 Comments »

Delphi attributes cannot use `const x: array of string` as argument

Posted by jpluimers on 2018/04/12

[WayBack] I want to annotate some of my enumerated types with human facing names. So I want to write: type[Names(‘Explicit time domain’, ‘Implicit time domain’,… – David Heffernan – Google+

This does not work:

constructor Create(const Values: array of string);

It seems to be in QC.

The reason is not obvious until you realise (thanks Stefan for wording that) that attribute constructor arguments are limited to anything that can be const. Open arrays nor dynamic arrays can be const (yes, nowadays you can have “consts” that are dynamic arrays but in fact they are compiler protected variables).

An alternative you might think works, but fails us using one attribute per enumeration element. But that’s where Delphi RTTI leaves you in the dark: it does not expose the RTTI for enumeration elements (likely doesn’t even generate it), only the the enumeration type itself.

So this fails:

type
  NameAttribute = class( TCustomAttribute )
  private
    FName: String;
  public
    constructor Create( AName : String );
    property Name: String read FName;
  end;

  TMyEnumeration = (
    [Name('One')]
    meOne,
    [Name('Two')]
    meTwo
  );

–jeroen

 

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Improve Android and iOS debug compilation speed – grijjy blog – Set the Debug information option to Limited Debug information

Posted by jpluimers on 2018/04/12

If you develop mobile apps with Delphi, you know it: compiling for Android and iOS is sloooooooooooooow, especially for debug builds. This little tip makes compiling Debug builds much faster……

Set the Debug information option to Limited Debug information

When I read a thing like that, I always think “how come I never thought about that before?” Well done Erik!

[WayBackImprove Android and iOS debug compilation speed – grijjy blog

via: [WayBack] Here’s a quick tip to improve the compilation speed of debug builds for iOS and Android… – Erik van Bilsen – Google+

–jeroen

Posted in Android, Delphi, Development, iOS Development, Mobile Development, Software Development | Leave a Comment »

Disable the Delphi clipboard history; originally by Attila Kovacs at https://plus.google.com/u/0/108426155215159556558/posts/6MBZuMYDTCD

Posted by jpluimers on 2018/04/07

Delphi Clipboard History

Delphi Clipboard History

[WayBack] Castalia had a Clipboard History for Delphi since a long time and since the acquisition of it around Delphi XE8, that was [Archive.isintegrated into the IDE for everyone to use as the [WayBack] “Delphi Clipboard History

Some people object to the history viewer, for instance:

  • stability reasons
  • security issues

Even though used by a lot of password managers to transfer saved passwords to applications requiring credentials, the clipboard isn’t really a secure place as it is a shared resource that any application can monitor: [WayBackIs a password in the clipboard vulnerable to attacks? – Information Security Stack Exchange.

It’s just that often the clipboard is about the only way to communicate date between two applications.

The real reason to get rid of the clipboard history is that in many Delphi versions it causes trouble with RichEdit controls: [Archive.isCastalia’s Clipboard history + TRichEdit = IDE deadlock | Andy’s Blog and Tools after Eugene Kotlyarov posted a [WayBack] bug issue on G+.

I’m still not sure why Castalia and Delphi include a Clipboard History and even show it by default as:

If you would want to build such a tool (that can hide itself when not needed), then use the free repository at chrisrolliston/CCR.Clipboard: Extended TClipboard implementation for Delphi (FMX and VCL) [Archive.isDitto download | SourceForge.net

At G+, Attila Kovacs published a non-intended version of the below version: [WayBack]

Source: Disable the Delphi clipboard history; originally by Attila Kovacs at https://plus.google.com/u/0/108426155215159556558/posts/6MBZuMYDTCD

–jeroen

Read the rest of this entry »

Posted in Castalia, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Do not use non-ASCII characters as identifiers – not all your tools support them well enough

Posted by jpluimers on 2018/04/05

For a very long time I’ve discouraged people from using non-ASCII characters in identifiers. It still holds.

In the past, transliterations messed things up. Even with increased support for Unicode, tools still screw non-ASCII characters up.

Delphi is not alone in this (the most important one is the DFM view as text support), see this report: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies (you need an account for this, but the report is visible for anyone):

Viewing a form as text fails with non ascii control or event names Comment

Steps:

  1. create a new VCL forms application
  2. drop a label onto the form
  3. change the name of that label to lblÜberfall (note the U-umlaut)
  4. switch to view as text
  • exp: DFM content shown as text
  • act: first line is shown incorrectly (see screenhsot)

–jeroen

Source: [RSP-16767] Viewing a form as text fails with non ascii control or event names – Embarcadero Technologies

via: [WayBack] Code of the day – – Thomas Mueller (dummzeuch) – Google+:

function TNameGenerator.StrasseToStrasse(const _Strasse: string): string;
begin
Result := _Strasse;
end;

Strasse := StrasseToStrasse(_Strasse);

Read the rest of this entry »

Posted in ASCII, Conference Topics, Conferences, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Encoding, Event, Mojibake, Software Development | Leave a Comment »

Wizard to change Delphi Icon so it used the Projects’ Icon

Posted by jpluimers on 2018/04/05

Thomas Mueller (dummzeuch) – Google+ wrote this: [WayBackJust an inspiration from attila kovacs (too many guys with this name on G+ to…:

A Delphi Wizard that adds a menu item so the Delphi Icon will change into the icon of the currently loaded project.

Can be useful if you have many Delphi instances open.

Source at [WayBackhttp://pisil.de/bds_icon.txt

via: [WayBackIs anybody able and have time to create an extension … change the icon with Application.Icon… – Attila Kovacs – Google+

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Efficient and easy-to-use JSON and BSON library – grijjy blog

Posted by jpluimers on 2018/04/04

Cool library for Delphi: [WayBackEfficient and easy-to-use JSON and BSON library – grijjy blog

On my list of stuff to use when I’m in need for JSON or BSON.

–jeroen

via: [WayBack] Looking for an efficient JSON/BSON library that supports a DOM, reader/writer interface and automatic serialization? Maybe this one has what you need… – Erik van Bilsen – Google+

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

A Post-Mortem on the Recent Developer Story Information Leak – Meta Stack Overflow

Posted by jpluimers on 2018/03/27

I wish many other companies would disclose post mortem information like this: [WayBackA Post-Mortem on the Recent Developer Story Information Leak – Meta Stack Overflow

via: [WayBackInteresting and very appropriate top commenthttp://meta.stackoverflow.com/questions/340960/a-post-mortem-on-the-recent-developer-story-information-leak – This is why I Code – Google+

–jeroen

 

 

Posted in .NET, Delphi, Development, Pingback, Power User, Software Development, Stackoverflow | Leave a Comment »

Update for DprojNormalizer | The Art of Delphi Programming

Posted by jpluimers on 2018/03/20

Important small [WayBack] Update for DprojNormalizer | The Art of Delphi Programming: it fixes usage of SanitizedProjectName in all other properties.

It is now at [WayBack] Version 2.2.1.

via: [WayBack] Small update for DprojNormalizer available – Uwe Raabe – Google+

–jeroen

 

Posted in Delphi, Development, Software Development | Leave a Comment »

Delphi: do not mix interfaces and classes part X

Posted by jpluimers on 2018/03/15

A very interesting discussion on what the mixing of interfaces and classes can get you into: [WayBack] I’ve got an interface with generics which accepts classes:IMyGeneric = interface…..end;What I want to do is to allow this interface to… – John Kouraklis – Google+

TL;DR: do not mix interfaces and classes.

As often, Asbjørn Heid chimes in showing some insight on clever mixing of the two with sample code accepting an unconstrained type. Don’t do that unless you really know what’s going on behind the scenes.

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | 4 Comments »