Skip to content

<vector>: _ITERATOR_DEBUG_LEVEL could detect forbidden aliasing #177

Description

WG21-N4830 [tab:container.seq.req]: "a.assign(n,t) Expects: [...] t is not a reference into
a."

This means that v.assign(5, v[0]) is undefined behavior. We can't detect every possible occurrence of this (I can easily devise unusual ownership scenarios), but because vector is contiguous, we could easily add an address range check that would detect common forms of aliasing. For other sequence containers, checking would be more costly, so it may be counterproductive.

We should consider investigating all member functions where aliasing is forbidden, and seeing how much validation we can perform.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions