Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Thread support    [ Add a report in this area ]  
Report #:  102766   Status: Closed
BeginThread should return NativeInt or THandle on Windows, not Integer
Project:  Delphi Build #:  16.0.4358.45540
Version:    16.3 Submitted By:   Chris Rolliston
Report Type:  Basic functionality failure Date Reported:  1/21/2012 7:05:07 AM
Severity:    Serious / Highly visible problem Last Updated: 9/5/2012 8:02:13 PM
Platform:    All versions Internal Tracking #:   289563
Resolution: Fixed (Resolution Comments) Resolved in Build: : 17.0.4625.53395
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: 1
Description
BeginThread returns Integer, however it should be either NativeInt or THandle on Windows. This is because the 'real' return type is THandle (=NativeUInt). While CreateThread is correctly declared in Winapi.Windows, it is wrongly declared (for 64 bit) in the include file used by System.pas (WindowsAPIs.inc). (On Win64, Integer is a 32 bit value where NativeInt and THandle are both 64 bit values.)

While using THandle would be the most correct thing to do (cf. what was done to FileOpen and friends for XE2 RTM), using NativeInt would keep things as they were for both Win32 and OSX32. If NativeInt is used however, then the result of BeginThread when called in TThread.Create should really be cast to THandle on being assigned to FHandle.

//USc: This would be an interface breaking change.
Steps to Reproduce:
1. Look at the source.
2. Observe the mismatch in types.


By USc:
- open $(BDS)\source\rtl\sys\System.pas
- look for the Windows version of BeginThread (line 1670 for XE2 U#3) and check the return parameter

expected: it is THandle
actual: it is Integer

- open $(BDS)\source\rtl\sys\WindowsAPIs.inc
- look for CreateThread (line 403 for XE2 U#3) and check the return parameter

expected: it is THandle
actual: it is Integer
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01