C++ Logo

std-proposals

Advanced search

[std-proposals] Use of volatile as function argument should not be deprecated.

From: Ryan P. Nicholl <rnicholl_at_[hidden]>
Date: Wed, 08 Jun 2022 21:46:58 +0000
Hello. I just wanted to point out a usage of volatile that I don't think should be deprecated. Namely, the use of volatile on a function argument.

This may sound weird but it can be useful to create a parameter like 'volatile bool collect_debug_info = false' that gets passed down to functions that get called by the function. The function is called with it always false so if the function is inlined the compiler will elide all the instances of it being checked. Simply editing the variable in the debugger can be useful to collect information this way for a specific execution without having to do anything more complicated. I would therefore suggest this be either 1. un-deprecated, possibly as a defect report for C++20 or 2. a new keyword or attribute specifically for values that are intended to be changed in a debugger so that it still warns people misusing it for threading. I'm also unsure about the value of deprecating += and such, but it's definitely understandable.

--
Ryan P. Nicholl
Tel: (678)-358-7765

Received on 2022-06-08 21:47:05