Skip to content

Fixed-size views alias temporaries returned by value #285

Description

@trsxvz

include/MGIS/Function/FixedSizeModifier.ixx:82, 88, 109, 115, 136, 142, 164, 171.

Finding. The call operator returns std::span<const real, N> built on this->evaluator(i).data(). When the wrapped evaluator returns by value, which unary and binary operations do, that object is a temporary and the returned span dangles. The concept that gates this only requires a data() member, which such temporaries have.

Effect. Wrapping any computed evaluator in a fixed-size view reads dead stack. Reproduced under the address sanitiser, with correct-looking values in optimised builds.

Fix. Return the value itself when the wrapped result is not a reference or a view, or restrict the concept to references and views.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions