microsoft / microsoft/wil

RESULT_DIAGNOSTICS_LEVEL 0

Open
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

When the diagnostics level is set to 0 using the following define:
#define RESULT_DIAGNOSTICS_LEVEL 0
In a release build (with all optimizations etc), I do expect that Return_Hr is not called in the generated code. However, this is not the case when using the RETURN_IF_FAILED macro:

if ( hr < 0 )
  {
    wil::details::in1diag0::Return_Hr(retaddr, hr);
    return hr;
  }

A possible solution might be do define different helper macros, depending on RESULT_DIAGNOSTICS_LEVEL. E.g.

#if RESULT_DIAGNOSTICS_LEVEL == 0
#undef RETURN_HR_FAIL
#define RETURN_HR_FAIL RETURN_HR_FAIL_EXPECTED
#undef RETURN_IF_WIN32_BOOL_FALSE
#define RETURN_IF_WIN32_BOOL_FALSE RETURN_IF_WIN32_BOOL_FALSE_EXPECTED
#undef RETURN_LAST_ERROR_IF_NULL
#define RETURN_LAST_ERROR_IF_NULL RETURN_LAST_ERROR_IF_NULL_EXPECTED
#undef RETURN_LAST_ERROR_IF
#define RETURN_LAST_ERROR_IF RETURN_LAST_ERROR_IF_EXPECTED
#undef RETURN_IF_WIN32_ERROR
#define RETURN_IF_WIN32_ERROR RETURN_IF_WIN32_ERROR_EXPECTED
#undef RETURN_HR_IF
#define RETURN_HR_IF RETURN_HR_IF_EXPECTED
#endif 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the definitions of RESULT_DIAGNOSTICS_LEVEL, RETURN_IF_FAILED, and the related RETURN_* macros. Inspect the optimized release output at level 0 and compare it with the expected macros listed in the issue. Done means RETURN_IF_FAILED and the affected helper macros do not emit a Return_Hr call in that configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.