Skip to content

Wrong function overload selection with long inheritance chain #8817

@vepadulano

Description

@vepadulano

Describe the bug

There seems to be a bug in the selection of a function overload with TObject-derived classes from Python:

import ROOT

ROOT.gInterpreter.Declare(
'''
class A: public TObject {};
class B: public A {};

void myfunc(const A &a){
    std::cout << "A" << std::endl;
}

void myfunc(const B &b){
    std::cout << "B" << std::endl;
}
''')

ROOT.myfunc(ROOT.A())
ROOT.myfunc(ROOT.B())

The snippet above outputs

A
A

Expected behavior

Snippet should output A\nB, And indeed from the root prompt I get the correct output

root [0] class A: public TObject {};
root [1] class B: public A {};
root [2] void myfunc(const A &a){
root (cont'ed, cancel with .@) [3]    std::cout << "A" << std::endl;
root (cont'ed, cancel with .@) [4]}
root [5] 
root [5] void myfunc(const B &b){
root (cont'ed, cancel with .@) [6]    std::cout << "B" << std::endl;
root (cont'ed, cancel with .@) [7]}
root [8] myfunc(A{});
A
root [9] myfunc(B{});
B

Setup

I tried it with both ROOT 6.24/02 and 6.20/06 (to check against old PyROOT), installed with conda on a Fedora32 machine

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions