Open p6rt opened 8 years ago
*** Note: I started writing this, but when I got to uint8, I realized it was taking too much time, so I gave up; this is a partial report*** ********************************************************************************************************************************************
There are some inconsistencies with the behaviours among the native types, including buggy behaviour of postdecrement/increment ops when the increment/decrement would make underflow/overflow occur.
Here's the summary table. Detailed code executes are in the attachment.
The meaning of headers: Assigning Too-Low Value: assigning value below one a type can hold, such as -1 to an unsigned type Assigning Too-High Value: same as above, except too high a value, such as a 50-bit value into int32 Underflow works: decrementing past lowest value flips over to the other end, such as decrementing a 0 on uint8 gives 256 Overflow works: same as above, except on the upper bounder, such as incrementing 256 on uint8 gives 0 Post-[de/in]cremnent on overflow works: best shown in an example:
WORKS: we flipped over the boundary and increment/decrement operation happened just once, returning the unmodified value in the second say():
\
BROKEN: operation happens TWICE and second say() behaves as if it were a prefix increment/decrement:
\
And here's the table showing the results of my evaluation:
[Type] [Assigning Too-Low Value] [Assigning Too-High Value] [Underflow works] [Overflow works] [Post-[de/in]crement on overflow works] int Runtime error Runtime error Yes Yes Yes int8 Value=0 Value=0 Yes Yes NO int16 Value=0 Value=0 Yes Yes NO int32 Value=0 Value=0 Yes Yes NO int64 Runtime error Runtime error Yes Yes Yes uint Behaves as int Behaves as int No (behaves as int) No (behaves as int) Yes (but behaves as int) uint8 Value rolls over Value rolls over No $x -= 1 works, but No $x +=1 work, but --$x gives negatives ++$x goes over 255
byte uint16 uint32 uint64 num num32 num64
int assigning too high/low value:
\
int underflow works:
\
int overflow works:
\
int postop works:
\
int8 assigning too high/low value:
\
int8 underflow works:
\
int8 overflow works:
\
int8 postop does NOT work (behaves as if it were ++$x and --$x, AND operation happens twice):
\
int16 underflow works:
\
int16 assigning too high/low value:
\
int16 overflow works:
\
int16 postop does NOT work (behaves as if it were ++$x and --$x, AND operation happens twice):
\
int32 assigning too high/low value:
\
int32 underflow works:
\
int32 overflow works:
\
int32 postop does NOT work (behaves as if it were ++$x and --$x, AND operation happens twice):
\
int64 assigning too high/low value:
\
int64 underflow works:
\
int64 overflow works:
\
int64 postop works:
\
uint assigning too high/low value:
\
uint underflow behaves like int:
\
uint overflow behaves like int:
\
uint postop works (but behaves like int):
\
uint8 assigning too high/low value:
\
uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
uint assigning too high/low value: uint underflow works: uint overflow works: uint postop works:
Migrated from rt.perl.org#127409 (status was 'new')
Searchable as RT127409$