C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept(static)

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 17 Sep 2026 07:50:06 -0700
On Thursday, 17 September 2026 04:20:27 Pacific Daylight Time Sebastian
Wittmeier via Std-Proposals wrote:
> Then you get check first, whether the file exists and avoid the exception.

Note you should never do that. That's a TOCTOU problem. If you mean to open
the file, you should open the file and react to the open failure problem.
Reasons include:

> Now you say that leads to a race condition. Another process could delete the
> file in between.

Or you could have had no permission to open it in the first place, so you still
have to deal with opening failures, whether you checked for existence or not.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-09-17 14:50:12