binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Negative values in 32-bit enum are extended to 64-bit

Open micro500 opened this issue 3 years ago • 3 comments

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:

  1. Add a new type definition:
enum TEST : int32_t
{
    BECOMES_64BIT = -1
};
  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
};

micro500 avatar Feb 27 '22 21:02 micro500

Actually as its signed it should probably be:

enum TEST : int32_t
{
    BECOMES_64BIT = -1
};

plafosse avatar Feb 28 '22 18:02 plafosse

I can no longer repro this on 3.1.3561. Did this get fixed with the clang parser addition?

0cyn avatar Jul 16 '22 21:07 0cyn

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

negasora avatar Jul 17 '22 00:07 negasora

Will be fixed in 3.2.3800

CouleeApps avatar Oct 22 '22 23:10 CouleeApps