Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-04

Potentially a slight little overflow issue in nx86mat.pas

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Skybuck Flying

Hello,

There could be a slight little overflow issue in unit "nx86mat.pas"

Line 174:
current_asmdata.asmlists[al_typedconsts].concat(tai_const.create_32bit(-(1 shl 31)));

Explanation of potential bug:

1 shl 31 results in 2147483648 which is already an integer overflow.

It is then tried to be negated towards -2147483648 which would be valid.

Question in this case is what does free pascal do ?

Does it convert the calculation towards 64 bit ? and then down casts it to 32 bit... that seems a bit unlikely to me...

Though I can imagine the compiler doing that inside itself for constants and then finally assigning the legal constant to "the/an integer"...

The mind wonders.. ;) =D

Bye,
Skybuck.

Reply by email