Bugs in the Delphi RTL/VCL

Top  Previous  Next

Pretranslated C++ code > Preparing Delphi code > Bugs in the Delphi RTL/VCL

In some cases Delphi2Cpp cannot process a unit though the Delphi compiler can That's because the automatically generated parser of Delphi2Cpp is more strict than the Delphi parser, which might be handwritten and tolerates bugs like the following in the System.pas of RAD Studio 10.2 Tokyo inside of the function "FSetExceptFlag":

 

{$ELSEIF defined(CPUX64) and defined(Linux)) }

 

It is obvious, that there is a closing parenthesis too much and the code should be corrected to:

 

{$ELSEIF defined(CPUX64) and defined(Linux) }

 

The next bug in the same file is:

 

{$IF not (defined(PC_MAPPED_EXCEPTIONS) or defined(SJLJ_BASED_EXCEPTIONS)) or defined(ZCX_BASED_EXCEPTIONS)) }

 

 

Such bugs unfortunately exist in all versions of the RTL/VCL at different positions. They can be found inside of the Delphi2Cpp IDE quite easily, because the position where the preprocessor or the parser stops is shown in the input editor. If you have moved the cursor, the position is shown again by use of the ShowLastError button.

 

 

Here is a list of some flaws in the RTL/VCL of RAD Studio 10.2 Tokyo.

 

System.ObjAuto.pas line 23:

 

{$IF SizeOf(Extended) >= 10)} // 10,12,16

  {$DEFINE EXTENDEDHAS10BYTES}

{$ENDIF}

 

{$IF SizeOf(Extended) = 10)}

  {$DEFINE EXTENDEDIS10BYTES}

{$ENDIF}

 

should be:

 

{$IF SizeOf(Extended) >= 10} // 10,12,16

  {$DEFINE EXTENDEDHAS10BYTES}

{$ENDIF}

 

{$IF SizeOf(Extended) = 10}

  {$DEFINE EXTENDEDIS10BYTES}

{$ENDIF}  

 

 

Internal.Unwinder.pas:

 

{$IFDEF MACOS}

const

  _U = '_';

  {$EXTERNALSYM _U}

{$ELSE !MACOS}

  _U = '';

  {$EXTERNALSYM _U}

{$ENDIF}

 

 

could be:

 

{$IFDEF MACOS}

const

  _U = '_';

  {$EXTERNALSYM _U}

{$ELSE !MACOS}

const

  _U = '';

  {$EXTERNALSYM _U}

{$ENDIF}

 

 

System.pas  line 6643:

 

 

{$ELSEIF defined(CPUX64) and defined(Linux)) }

->

{$ELSEIF defined(CPUX64) and defined(Linux) }

 

line 24087:

 

{$IF not (defined(PC_MAPPED_EXCEPTIONS) or defined(SJLJ_BASED_EXCEPTIONS)) or defined(ZCX_BASED_EXCEPTIONS)) }

->

{$IF not (defined(PC_MAPPED_EXCEPTIONS) or defined(SJLJ_BASED_EXCEPTIONS)) or defined(ZCX_BASED_EXCEPTIONS) }

 

 

Vcl.Imaging.GifImg.pas  line 2421:

 

SetColors(GetPaletteEntries(Palette, 0, 256, nil^));

->

SetColors(GetPaletteEntries(Palette, 0, 256, nil));

 

 

WinAPI.DXFile.pas line 37:

 

 

(*$HPPEMIT '#include "dxfile.h"'{*)

(*$HPPEMIT '#include "rmxfguid.h"'{*)

(*$HPPEMIT '#include "rmxftmpl.h"'{*)

 

->

 

(*$HPPEMIT '#include "dxfile.h"'*)

(*$HPPEMIT '#include "rmxfguid.h"'*)

(*$HPPEMIT '#include "rmxftmpl.h"'*)

 

 

ToolsApi/ToolsApi.pas line 123/250/252

 

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAStreamModifyTime,0x49F2F63F,0x60CB,0x4FD4,0xB1,0x2F,0x81,0x67,0xFC,0x79,0xB2,0x93);*)

...

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAToolsFilterNotifier,0xCEF1F13A,0xE877,0x4F20,0x88,0xF2,0xF7,0xE2,0xBA,0x61,0xAA,0xF4); *)

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAToolsFilter,0x8864B891,0x9B6D,0x4002,0xBB,0x2E,0x1D,0x6E,0x59,0xBF,0xA4,0x9A); *)

.

(*$HPPEMIT 'DEFINE_GUID(IID_IOTATypeLibrary, 0x7A2F5910,0x58D2,0x448E,0xB4,0x57,0x2D,0xC0,0x1E,0x85,0x3D,0x46);*)

 

->

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAStreamModifyTime,0x49F2F63F,0x60CB,0x4FD4,0xB1,0x2F,0x81,0x67,0xFC,0x79,0xB2,0x93);'*)

...

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAToolsFilterNotifier,0xCEF1F13A,0xE877,0x4F20,0x88,0xF2,0xF7,0xE2,0xBA,0x61,0xAA,0xF4);'*)

(*$HPPEMIT 'DEFINE_GUID(IID_IOTAToolsFilter,0x8864B891,0x9B6D,0x4002,0xBB,0x2E,0x1D,0x6E,0x59,0xBF,0xA4,0x9A);'*)

.

(*$HPPEMIT 'DEFINE_GUID(IID_IOTATypeLibrary, 0x7A2F5910,0x58D2,0x448E,0xB4,0x57,0x2D,0xC0,0x1E,0x85,0x3D,0x46);'*)

 

 

 

\rtl\osx\Macapi.ObjectiveC.pas

 

there are several occurrences of:

 

 

{$ELSE Defined(...

 

 

This syntax isn't documented and seems not to be used anywhere else (with one exception in SysUtils). The Code can be processed, when {$ELSE is changed to {$ELSEIF

 

 

Flaws in the RTL of RAD Studio 10.4.1  Alexandria

 

 

{$IF SizeOf(Extended) >= 10)}

->

{$IF SizeOf(Extended) >= 10}

 

 

{$IF SizeOf(Extended) = 10)}

->

{$IF SizeOf(Extended) = 10}

 

 

Posix.SysSocket.pas

 

 

function CMSG_NXTHDR

 

 

System.pas

 

{$ELSEIF defined(CPUX64) and defined(Linux)) }

->

{$ELSEIF defined(CPUX64) and defined(Linux) }

 

 

{$IF Defined(OSX64) or defined(IOSSIMULATOR) and defined(CPUX64))}

->

{$IF Defined(OSX64) or defined(IOSSIMULATOR) and defined(CPUX64)}

 

 

{$ELSEIF defined(CPUX64) and defined(Linux)) }

->

{$ELSEIF defined(CPUX64) and defined(Linux) }

 

 

procedure Set8087CW(NewCW: Word);

function Get8087CW: Word;

procedure SetMXCSR(NewMXCSR: UInt32);

procedure SetMXCSRExceptionFlag(NewExceptionFlag: UInt32);

procedure ClearMXCSRStatus(ExceptionFlag: UInt32);

{$IF defined(CPUX86) and defined(ASSEMBLER)}

 

 

{$IF not (defined(PC_MAPPED_EXCEPTIONS) or defined(SJLJ_BASED_EXCEPTIONS)) or defined(ZCX_BASED_EXCEPTIONS)) }                                            

->

{$IF not (defined(PC_MAPPED_EXCEPTIONS) or defined(SJLJ_BASED_EXCEPTIONS)) or defined(ZCX_BASED_EXCEPTIONS) }

                                           

 

 

 

System.Rtti.pas: unknown  SizeOf(TValue)

 

Winapi.DXFile.pas cannot parse:

 

(*$HPPEMIT '#include "dxfile.h"'{*)

(*$HPPEMIT '#include "rmxfguid.h"'{*)

(*$HPPEMIT '#include "rmxftmpl.h"'{*)

 

 

 

 

 

 

 

 

 

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content