Skip to content

[BUG]: new make_key_iterator/make_value_iterator in 2.8.0 may return reference to temporary #3347

Description

@bmerry

Required prerequisites

Problem description

I was a bit too clever (or not clever enough) when I refactored make_key_iterator and added make_value_iterator. For a normal, STL iterator everything is fine, but an iterator where dereferencing synthesizes a value on the fly (such as an input iterator) doesn't work correctly (unless it returns a pair of references). Due to some subtleties of decltype, the accessor functors end up returning a reference to a temporary.

I will work on a fix - just filing an issue so long for reference.

Reproducible example code

bmerry@cbf8495 adds a unit test that demonstrates the issue. At compile time it warns about returning a reference to a temporary, and at runtime it segfaults.

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

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions