Skip to content

Regression when reading a type spelled via a dependent alias #23055

Description

@jmcarcell

Check duplicate issues.

  • Checked for duplicates

Description

In tests in Gaudi using ROOT's master we have found out that there are tests reading a number of tracks and they do not read what was written, making tests fail.

Bisection seems to lead to 081af22.

Reproducer (🤖)

#include <TClass.h>
#include <TInterpreter.h>
#include <TStreamerElement.h>
#include <TStreamerInfo.h>

#include <iostream>

void legacy_streamer_typename() {
  gInterpreter->Declare( R"cpp(
    #include <vector>

    namespace repro {
      struct Track {
        int value{};
      };

      template <typename T>
      struct Container {
        typedef typename std::vector<T*> seq_type;
        seq_type m_sequential;
      };
    }
  )cpp" );

  auto* klass = TClass::GetClass( "repro::Container<repro::Track>" );
  auto* info = klass ? dynamic_cast<TStreamerInfo*>( klass->GetStreamerInfo() ) : nullptr;
  Int_t offset = 0;
  auto* element = info ? info->GetStreamerElement( "m_sequential", offset ) : nullptr;
  if ( !element ) {
    std::cerr << "setup failed" << std::endl;
    return;
  }

  std::cout << "stored=" << element->GetTypeName() << std::endl;

  // Simulate ROOT rebuilding metadata read from an old file against the
  // current class layout. This is the path taken by the Gaudi file read.
  info->ResetBit( TStreamerInfo::kBuildOldUsed );
  info->BuildOld();

  std::cout << "new-type=" << element->GetNewType() << std::endl;
}

Where the key line is typedef typename std::vector<T*> seq_type. Removing typename fixes it for this macro (I haven't tested yet if it does in Gaudi).

Output in ROOT 6.40.02:

Processing legacy_streamer_typename.C...
stored=vector<repro::Track*>
new-type=300

Output in ROOT master:

Processing legacy_streamer_typename.C...
stored=typename std::vector<repro::Track*>
new-type=-2
Warning in <TStreamerInfo::BuildOld>: Cannot convert repro::Container<repro::Track>::m_sequential from type: typename std::vector<repro::Track*> to type: vector<repro::Track*>, skip element

ROOT version

6.40.02 works, master doesn't

Installation method

LCG stacks

Operating system

Linux

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions