[Bug c++/25325] New: enum class inherited from typedef of unsigned type does not handle values with high bit set

sphink at gmail dot com sourceware-bugzilla@sourceware.org
Mon Dec 30 22:07:00 GMT 2019


https://sourceware.org/bugzilla/show_bug.cgi?id=25325

            Bug ID: 25325
           Summary: enum class inherited from typedef of unsigned type
                    does not handle values with high bit set
           Product: gdb
           Version: 8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: sphink at gmail dot com
  Target Milestone: ---

Consider
```
#include <stdint.h>

enum Op : uint8_t {
    Op_A = 1,
    Op_B = 127,
    Op_C = 128
};

int main() {
    Op a = Op::Op_A;
    Op b = Op::Op_B;
    Op c = Op::Op_C;
    return (a == b) || (b == c);
}
```

(gdb) p Op_A
$1 = Op_A
(gdb) p Op_C
$1 = -128
(gdb) p (Op)128
$1 = -128

If `uint8_t` is replaced with `unsigned char`, then it will work as intended.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list