Skip to content

Bug: winrt::box_value(std::wstring_view(...)) may cause abort #1527

@justanotheranonymoususer

Description

Version

No response

Summary

I'm bitten by this for the second time, and it's not pleasant to debug. I have code like:

Blabla(winrt::box_value(GetStringView(...)));

It seems that if GetStringView returns std::wstring_view which happens to end with a null terminator, it works, but if not, then abort is called and the app crashes.

Ideally it should just work correctly. Less ideally, it shouldn't compile without an explicit hstring(...) conversion. Even less ideally, it should always crash. But now, it crashes only in the less common cases, which bits me in the most inconvenient times.

I don't have an isolated repro right now, I'm working on a large codebase, let me know if you need one.

Reproducible example

Expected behavior

No response

Actual behavior

No response

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions