binaryninja-api
binaryninja-api copied to clipboard
Negative values in 32-bit enum are extended to 64-bit
Version and Platform (required):
- Binary Ninja Version: 3.0.3268-dev
- OS: Windows 10 64-bit
Bug Description: Adding a negative value entry to an enum type is extended to the equivalent 64-bit when the enum is set to a storage of int32_t.
Steps To Reproduce:
- Add a new type definition:
enum TEST : int32_t
{
BECOMES_64BIT = -1
};
- Note that the definition is changed to:
enum TEST : int32_t
{
BECOMES_64BIT = 0xffffffffffffffff
};
Expected Behavior: Due to the 32-bit storage I would have expected the enum definition to become:
enum TEST : int32_t
{
BECOMES_64BIT = 0xffffffff
};
Actually as its signed it should probably be:
enum TEST : int32_t
{
BECOMES_64BIT = -1
};
I can no longer repro this on 3.1.3561. Did this get fixed with the clang parser addition?
On 3.1.3561-dev with member a=-1:
enum asd : int32_t
{
a = 0xffffffff
};
enum asd : uint32_t
{
a = 0xffffffffffffffff
};
With uint32_t, I couldn't define the type with a=-1, I had to use a positive value first then change it to -1
Will be fixed in 3.2.3800