Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[PyROOT] cppyy selects explicit template instantiation

Aperta
#21,329 0 commenti 0 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@guitargeek ci sta già lavorando.

Dal 19/2/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug in:Python Interface
Check duplicate issues.
  • Checked for duplicates
Description

When a function takes a mandatory template argument that also cannot be deduced, cppyy sometimes uses an explicit instantiation.

Reproducer
>>> import ROOT
>>> ROOT.gInterpreter.Declare("template <typename T> std::size_t get_size() { return sizeof(T); }")
True
>>> ROOT.gInterpreter.Declare("template std::size_t get_size<int>();")
True
>>> ROOT.get_size()
4
>>> ROOT.get_size[""]()
4

I would expect the call to fail:

>>> import ROOT
>>> ROOT.gInterpreter.Declare("template <typename T> std::size_t get_size() { return sizeof(T); }")
True
>>> ROOT.get_size()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Template method resolution failed:
  Failed to instantiate "get_size()"
>>> ROOT.get_size[""]()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Could not find "get_size<>" (set cppyy.set_debug() for C++ errors):
  Failed to instantiate "get_size<>()"

Interestingly, the behavior is different after it failed once:

>>> ROOT.gInterpreter.Declare("template std::size_t get_size<int>();")
True
>>> ROOT.get_size()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Template method resolution failed:
  Failed to instantiate "get_size()"
>>> ROOT.get_size[""]()
4
>>> ROOT.get_size()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Template method resolution failed:
  Failed to instantiate "get_size()"

Now it only works with get_size[""]()...?!

ROOT version

master

Installation method

from source

Operating system

Linux

Additional context

No response

Lingua principale
C++
Stelle
3.3k
Fork
1.6k
Merge medio
2g 7h
PR unite (30g)
180

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di root-project/root

Tutte le issue di root-project/root

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.