cling icon indicating copy to clipboard operation
cling copied to clipboard

unable to resolve type alias to enum

Open huili80 opened this issue 1 year ago • 0 comments

  • [x] Checked for duplicates

Describe the bug

I originally reported a bug in cppyy, https://github.com/wlav/cppyy/issues/215, but was told it's a Cling issue that it's "unable to resolve the type".

import cppyy
code = """
using type = std::byte; // or any other enum smaller than 4 bytes
type x{};
std::array<char,4> a = {1,2,3,4};
"""
cppyy.cppdef(code)
print(hex(cppyy.gbl.x))
cppyy.gbl.x = 0x0fffffff
print([ord(cppyy.gbl.a[i]) for i in range(4)])
0x3020100
[255, 255, 15, 4]

Expected behavior

0x0
[1, 2, 3, 4]

To Reproduce

The combination of

  • using a type alias to declare a variable
  • type being an enum smaller than 4 bytes

is required to reproduce this behavior.

Setup

cppyy 3.0.0 and 3.1.2.

Additional context

See the bug report in cppyy, https://github.com/wlav/cppyy/issues/215.

huili80 avatar Feb 17 '24 13:02 huili80