View Issue Details

IDProjectCategoryView StatusLast Update
0034712FPCRTLpublic2019-02-09 18:53
ReporterThaddy de KoningAssigned ToMarco van de Voort 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSwindowsOS Version
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0034712: makerop4 should take longword parameters, not longint...
Descriptionmakerop4 should take longword parameters, not longint...
Steps To ReproduceNow:
function MAKEROP4(fore,back : longint) : DWORD;
begin
  MAKEROP4:=DWORD((DWORD(back shl 8) and $FF000000) or DWORD(fore));
end;

Should be:

function MAKEROP4(fore,back : longword) : longword; inline;
begin
  result:= back shl 8 and $FF000000 or fore;
end;
Additional Information- wininc: All the surrounding functions in wininc are also subject to this issue: longint vs longword. winunits-jedi handles them correctly.
- see also: http://forum.lazarus.freepascal.org/index.php?topic=43570.msg305157#msg305157
TagsNo tags attached.
Fixed in Revision41269
FPCOldBugId
FPCTarget
Attached Files

Activities

Serge Anvarov

2018-12-17 19:02

reporter   ~0112651

Maybe as in JwaWinGDI as a DWORD?
function MAKEROP4(Fore, Back: DWORD): DWORD; inline;
begin
  Result := ((Back shl 8) and DWORD($FF000000)) or Fore;
end;

Thaddy de Koning

2018-12-17 19:38

reporter   ~0112652

Last edited: 2018-12-17 20:20

View 3 revisions

No. The brackets are not necessary because all operators have equal weight so are evaluated left to right. The cast is also nonsense idf the parameters are already longword (or dword).Hex literals are unsigned.

{$mode objfpc}
function MAKEROP4(fore,back : dword) : dword; inline;
begin
  result:=((back shl 8) and $FF000000) or fore;
end;

function MAKEROP4_2(fore,back : longword) : longword; inline;
begin
  result:= back shl 8 and $FF000000 or fore;
end;

function MAKEROP4_ASerge(Fore, Back: DWORD): DWORD; inline;
begin
  Result := ((Back shl 8) and DWORD($FF000000)) or Fore;
end;

begin
 writeln(makerop4($FFFfffff,$FFFFFF));
 writeln(makerop4_2($FFFfffff,$FFFFFF));
 writeln(makerop4_ASerge($FFFFFFFF,$FFFFFF);
end.
You can test all border cases. Does not matter.

Marco van de Voort

2019-02-09 18:53

manager   ~0113996

fixed.

Issue History

Date Modified Username Field Change
2018-12-17 18:52 Thaddy de Koning New Issue
2018-12-17 19:02 Serge Anvarov Note Added: 0112651
2018-12-17 19:38 Thaddy de Koning Note Added: 0112652
2018-12-17 19:39 Thaddy de Koning Note Edited: 0112652 View Revisions
2018-12-17 20:20 Thaddy de Koning Note Edited: 0112652 View Revisions
2019-02-09 18:53 Marco van de Voort Fixed in Revision => 41269
2019-02-09 18:53 Marco van de Voort Note Added: 0113996
2019-02-09 18:53 Marco van de Voort Status new => resolved
2019-02-09 18:53 Marco van de Voort Fixed in Version => 3.3.1
2019-02-09 18:53 Marco van de Voort Resolution open => fixed
2019-02-09 18:53 Marco van de Voort Assigned To => Marco van de Voort