Longint arithmetic is expanded to the native integer type, or in some cases 64-bit.
Unless you retype it to the same type you are working with (here LongInt)...
32 bit Delphi behaves the same as 32 bit FPC, tried for ShortInt, SmallInt now.
In 32 bit Delphi SHR produces negative value from negative value for ShortInt, SmallInt but positive value for Longint.
So generally it is not FPC bug.
Don't have the 64bit Delphi compiler now and won't reopen the issue although I am not very satisfied with this way of compilation.
When working with some bit width I would expect all the operations would take place in that bit width (from my point of view, of course compiler can internally use the most effective way).
SHR is declared as bitwise operator so I would always expect for a negative number to get positive number when SHRed.
As is the case when you SHR this in 32 bit width with 32 bit compiler.
And as is the case when you retype the result as described in my second comment to the bug report.
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/expressions_xml.htmlBut why to explicitly retype when the operation result should be already of that type?
I don't know.
Either way, the LZMA decoder works for me now on 64bit compiler, the retyping solved this (your solution would probably either, didn't try).
Hope this thread will help to somebody else trying to use it.