microsoft / microsoft/terminal

Code Health: Consider disabling warning C26440

Open
#4,267 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-CodeHealth Issue-Task Product-Meta
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

In one of the PRs I'm working on, I found I was getting errors from the audit mode build because it wanted me to declare certain methods as noexcept (warning C26440). But the methods in question were calling the std:array::at method, which throws an exception, so I would have thought they couldn't be noexcept.

You can see an example of this in the TerminalSettings::GetColorTableEntry method:

https://github.com/microsoft/terminal/blob/a60ed520649920cc50167d58075e69302ccc5ce9/src/cascadia/TerminalSettings/TerminalSettings.cpp#L76-L79

It's calling std:array::at, so it clearly can throw an exception, but it's still declared as noexcept. And removing that noexcept will trigger above-mentioned error in the audit mode build.

So what is the recommended practice here? Do we just add noexcept to the method even though that's not actually true? Do we suppress the warning on a case by case basis? (Per function, or per compilation unit?) Or should we consider disabling the warning for the entire project, at least until it's more reliable?

Contributor guide

Open the contributing guide

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 with TerminalSettings::GetColorTableEntry in src/cascadia/TerminalSettings/TerminalSettings.cpp and review how audit mode reports warning C26440. Compare the noexcept behavior of std::array::at with the project's warning configuration, then determine whether the warning should be suppressed locally or project-wide; done means a documented, agreed recommendation or configuration change.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.