microsoft / wil

Windows Implementation Library
MIT License
2.57k stars 234 forks source link

try_copy_to should be noexcept? #446

Open bobbymcr opened 3 months ago

bobbymcr commented 3 months ago

The wil::com_ptr_t method try_copy_to is supposed to be a non-exceptional way to copy the held COM interface pointer into a raw output pointer (potentially of a different interface type). However, it's not marked noexcept which can cause problems when using high warning levels on static analyzers (e.g. see C26447 from the C++ Core Guidelines checker). It seems like try_copy_to and the transitively called functions in query_policy should be marked noexcept, as they all return error codes and only interact with other non-exceptional APIs (e.g. QueryInterface).