# Potential bug in vtkInformationVector::Remove()

**URL:** https://discourse.vtk.org/t/potential-bug-in-vtkinformationvector-remove/16353
**Category:** Development
**Tags:** code
**Created:** [March 24, 2026, 3:36am UTC](https://discourse.vtk.org/t/potential-bug-in-vtkinformationvector-remove/16353 "2026-03-24T03:36:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sunjnn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sunjnn](https://discourse.vtk.org/u/sunjnn)
#### Post date: [March 24, 2026, 3:36am UTC](https://discourse.vtk.org/t/potential-bug-in-vtkinformationvector-remove/16353/1 "2026-03-24T03:36:49Z")

</div>

There appears to be a logic issue in `vtkInformationVector::Remove()` that causes incorrect behavior when removing information objects from the vector, particularly when the same object appears multiple times.

The current implementation iterates forward through the vector and erases elements without adjusting the loop index:

> <https://github.com/Kitware/VTK/blob/c50195cf646f04243d8601a613d5384696b2fe97/Common/Core/vtkInformationVector.cxx#L158>

Issues identified:

After erase(), all subsequent elements shift left by one position, but the loop continues with i++, effectively skipping the next element.

Reproduction Test Case:

```cpp
#include <iostream>
#include "vtkInformation.h"
#include "vtkInformationVector.h"

int main()
{
  vtkInformation *info = vtkInformation::New();
  vtkInformationVector *vec = vtkInformationVector::New();

  // Append the same info object twice
  vec->Append(info);
  vec->Append(info);
  
  std::cout << "Before Remove: " << vec->GetNumberOfInformationObjects() << std::endl; // 2
  
  vec->Remove(info);
  
  std::cout << "After Remove: " << vec->GetNumberOfInformationObjects() << std::endl;
  // Expected: 0, but got 1

  info->Delete();
  vec->Delete();
  
  return 0;
}

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [March 24, 2026, 10:56am UTC](https://discourse.vtk.org/t/potential-bug-in-vtkinformationvector-remove/16353/2 "2026-03-24T10:56:09Z")

</div>

Agreed, it should i-- as well, please open a MR.
