Skip to content

Cannot pass enum with fixed underlying type from std namespace as function argument in python any longer #23615

Closed

Description

@tmadlener

Check duplicate issues.

  • Checked for duplicates

Description

I am fairly certain this is somewhat of a niche issue and a fix is somewhat straight forward, but it still trips our CI on builds with the latest ROOT. I strongly suspect #21261 as culprit given the nature of the issue, but I haven't run any more fine grained bisection other than checking that this still worked with the dev3 build from Friday (Oct 2) and doesn't with todays dev3 build.

Essentially, when trying to pass a scoped enum that uses a fixed width integer from the std namespace as underlying type as a function argument, I run into a TypeError: could not convert argument 1: [InstanceConverter].

/// This works
enum class Location { AtOther = 0, AtIP = 1, AtVertex = 5};
int foo(Location loc) { return static_cast<int>(loc); }

/// But this doesn't
enum class Location : std::int32_t { AtOther = 0, AtIP = 1, AtVertex = 5};
int foo(Location loc) { return static_cast<int>(loc);

/// Curiously, this also works
enum class Location : int32_t { AtOther = 0, AtIP = 1, AtVertex = 5};
int foo(Location loc) { return static_cast<int>(loc);

Reproducer

Consider the following minimal repro.py

#!/usr/bin/env python3

import ROOT

ROOT.gInterpreter.Declare(r"""
#include <cstdint>

namespace repro {
enum class Location : std::int32_t { AtOther = 0, AtIP = 1, AtVertex = 5 };
std::int32_t foo(Location loc) { return static_cast<std::int32_t>(loc); }
}
""")

print(ROOT.repro.foo(ROOT.repro.Location.AtIP))

Running it on last Fridays dev3 stack

$ source /cvmfs/sft.cern.ch/lcg/views/dev3/Fri/x86_64-ubuntu2404-gcc13-opt/setup.sh 
$ python3 repro.py
1

Running it on todays dev3 stack

$ source /cvmfs/sft.cern.ch/lcg/views/dev3/Mon/x86_64-ubuntu2404-gcc13-opt/setup.sh 
$ python3 repro.py
Traceback (most recent call last):
  File "<path/to>/repro.py", line 15, in <module>
    print(ROOT.repro.foo(ROOT.repro.Location.AtIP))
          ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int repro::foo(repro::Location loc) =>
    TypeError: could not convert argument 1: [InstanceConverter]

ROOT version

ROOT v6.41.01
Built for linuxx8664gcc on Oct 04 2026, 22:45:42
From heads/master@v6-39-99-2057-ga8d6e8b46ec
With g++ (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 std202002
Binary directory: /cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev3/Mon/ROOT/a8d6e8b4/x86_64-ubuntu2404-gcc13-opt/bin

Installation method

LCG dev3 stack

Operating system

any, I would assume (I have tested Ubuntu and EL9)

Additional context

It is almost certainly unrelated to the issue at hand, but whether the enum is scoped or not doesn't make any difference, it seems to really be the namespace in the underlying type that causes the issue.

Activity

  1. changed the title [-]Cannot pass scoped enum with fixed underlying type from std namespace as function argument[/-] [+]Cannot pass enum with fixed underlying type from std namespace as function argument[/+] on Oct 5, 2026
  2. changed the title [-]Cannot pass enum with fixed underlying type from std namespace as function argument[/-] [+]Cannot pass enum with fixed underlying type from std namespace as function argument in python any longer[/+] on Oct 5, 2026
  3. tmadlener commented on Oct 5, 2026

    @tmadlener
    ContributorAuthor

    This is almost certainly fixed by compiler-research/cppjit#135

  4. self-assigned this
    on Oct 6, 2026
  5. aaronj0 commented on Oct 6, 2026

    @aaronj0
    Contributor

    This is almost certainly fixed by compiler-research/cppjit#135

    Indeed, that PR was merged and we'll have that included in the next bump in the cppjit/CppInterOp stack.

  6. tmadlener commented on Oct 6, 2026

    @tmadlener
    ContributorAuthor

    Is there a plan for when that will happen already by any chance? It's not extremely urgent, I think, but it would give us a feeling of whether it makes sense to put temporary fixes in place on our end or whether we can just wait for this to be fixed in ROOT / cppjit.

  7. aaronj0 commented on Oct 6, 2026

    @aaronj0
    Contributor

    Is there a plan for when that will happen already by any chance? It's not extremely urgent, I think, but it would give us a feeling of whether it makes sense to put temporary fixes in place on our end or whether we can just wait for this to be fixed in ROOT / cppjit.

    Will land as #23626 when that's green

  8. jmcarcell commented on Oct 8, 2026

    @jmcarcell
    Contributor

    This seems to be fixed today in dev3 builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions