Skip to content

unable to resolve type alias to enum #521

Open
@huili80

Description

@huili80
  • Checked for duplicates

Describe the bug

I originally reported a bug in cppyy, wlav/cppyy#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, wlav/cppyy#215.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions