Skip to content

Bug: winrt::hresult_error::originate asserts when using a clr.dll based error info object #1380

@ChrisGuzak

Description

@ChrisGuzak

Version

C++/WinRT v2.0.220418.1

Summary

In winrt::hresult_error::originate, running in the context of a Microsoft::VisualStudio::CppUnitTestFramework project, where the error info object is provided by clr.dll and it does not implement IRestrictedErrorInfo. the WINRT_VERIFY(info.try_as(m_info)) line fails the assert.

base.h, ~4892

            com_ptr<impl::IErrorInfo> info;
            WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void()));
            WINRT_VERIFY(info.try_as(m_info));

Is this a bug in the CLR or is the design intended to support this?

Reproducible example

TEST_METHOD(CatchCppWinRtException)
{
    try
    {
        winrt::check_hresult(E_NOT_SET);
    }
    catch (...)
    {
    }
}

Expected behavior

no assert, but I'm not sure if this is bug in the CLR or cppwinrt

Actual behavior

assert, in debug build

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