View Issue Details

IDProjectCategoryView StatusLast Update
0037755FPCCompilerpublic2020-09-16 20:39
Reporterrunewalsh Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionwon't fix 
Summary0037755: SAR intrinsic overloads
DescriptionSAR intrinsics (SarLongint, SarInt64, ...) are much like a workaround for SHR not performing arithmetic shift for signed types, so I think it will be convenient to have plain ‘Sar’ overloads on top of them, as their effect doesn't depend on type, unlike, say, ROL/ROR, and the SHR operator to which they are similar is also „overloaded“ for all types.
Additional InformationFor me, I just redefined

function Sar(const value: int8): int8; [internproc: fpc_in_sar_x];
function Sar(const value: int8; shift: byte): int8; [internproc: fpc_in_sar_x_y];
function Sar(const value: int16): int16; [internproc: fpc_in_sar_x];
function Sar(const value: int16; shift: byte): int16; [internproc: fpc_in_sar_x_y];
function Sar(const value: int32): int32; [internproc: fpc_in_sar_x];
function Sar(const value: int32; shift: byte): int32; [internproc: fpc_in_sar_x_y];
function Sar(const value: int64): int64; [internproc: fpc_in_sar_x];
function Sar(const value: int64; shift: byte): int64; [internproc: fpc_in_sar_x_y];

and it seems to be working.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Florian

2020-09-16 19:25

administrator   ~0125571

The effect of sar depends on the size of the type: 255 "sar" 1 might be 255 or 127 depending if 255 is considered being 1 byte or 2 bytes or larger. So these overloads would cause more confusion than solving anything.

runewalsh

2020-09-16 20:39

reporter   ~0125575

Left operand is always signed, so it can't be both 255 and 1 byte long unless explicitly told otherwise. If a user really needs 1-byte 255, he can cast it manually, i. e. Sar(int8(255), ...).

But okay :(

Issue History

Date Modified Username Field Change
2020-09-16 14:31 runewalsh New Issue
2020-09-16 19:25 Florian Assigned To => Florian
2020-09-16 19:25 Florian Status new => resolved
2020-09-16 19:25 Florian Resolution open => won't fix
2020-09-16 19:25 Florian FPCTarget => -
2020-09-16 19:25 Florian Note Added: 0125571
2020-09-16 20:39 runewalsh Note Added: 0125575