Repository: root-project/root (2026-07-20T09:21:38Z)

Issue:
[ntuple] REntry::BindRawPtr() does not type-check
### Check duplicate issues.

- [ ] Checked for duplicates

### Description

The `BindRawPtr()` call should do a runtime check of the given type against the model type. This is not the case for its overload receiving a field name.

### Reproducer

Create a model with, e.g., an `RVec<int>` field and use `BindRawPtr()` with the field name and an `RVec<float>`. This won't fail at runtime as it should but read wrong data.

### ROOT version

master

### Installation method

from sources

### Operating system

n/a

### Additional context

_No response_


Discussion:
Hi @jblomer,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
:robot:

Hi @jblomer,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
:robot:

Hi @jblomer,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
:robot:

Hi @jblomer,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
:robot:




Patch:
diff --git a/tree/ntuple/inc/ROOT/REntry.hxx b/tree/ntuple/inc/ROOT/REntry.hxx
index 33e5a8c2ab235..590e39853eff2 100644
--- a/tree/ntuple/inc/ROOT/REntry.hxx
+++ b/tree/ntuple/inc/ROOT/REntry.hxx
@@ -215,7 +215,7 @@ public:
    template <typename T>
    void BindRawPtr(std::string_view fieldName, T *rawPtr)
    {
-      BindRawPtr<void>(GetToken(fieldName), rawPtr);
+      BindRawPtr<T>(GetToken(fieldName), rawPtr);
    }
 
    /// Get the (typed) pointer to the value for the field referenced by `token`.


Test patch:
diff --git a/tree/ntuple/test/ntuple_basics.cxx b/tree/ntuple/test/ntuple_basics.cxx
index 9d6b375275f30..1737711744d38 100644
--- a/tree/ntuple/test/ntuple_basics.cxx
+++ b/tree/ntuple/test/ntuple_basics.cxx
@@ -817,6 +817,12 @@ TEST(REntry, Basics)
    EXPECT_EQ("float", e->GetTypeName("pt"));
    EXPECT_EQ("float", e->GetTypeName(model->GetToken("pt")));
 
+   float rawPt;
+   double wrongType;
+   e->BindRawPtr("pt", &rawPt);
+   EXPECT_EQ(&rawPt, e->GetPtr<float>("pt").get());
+   EXPECT_THROW(e->BindRawPtr("pt", &wrongType), ROOT::RException);
+
    auto ptrPt = std::make_shared<float>();
    e->BindValue("pt", ptrPt);
    EXPECT_EQ(ptrPt.get(), e->GetPtr<float>("pt").get());