Skip to content

Commit

Permalink
C++20: Fix -Wvolatile warnings
Browse files Browse the repository at this point in the history
C++20 has completely deprecated `volatile`, and GCC enables multiple
warnings to catch invalid volatile uses.

Signed-off-by: Taylor Foxhall <tfoxhall@bloomberg.net>
  • Loading branch information
hallfox committed Jul 26, 2024
1 parent 100721e commit 9a10c65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ int doWork_cpuIntensive()
volatile unsigned int sum = 0;
for (int i = 0; i < (k_1K * multiplier); ++i) {
volatile int a = 50 * 9873 / 3;
sum += a;
sum = sum + a;

volatile int b = a * (a ^ (~0U));
sum += b;
sum = sum + b;

volatile int c = (a * (b ^ (~0U))) % 999983;
sum += c;
sum = sum + c;
}

return sum;
Expand Down
20 changes: 0 additions & 20 deletions src/groups/mwc/mwcu/mwcu_weakmemfn.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ static void test1_weakMemFn_resultType()
(bsl::is_same<mwcu::WeakMemFnResult<const R>,
mwcu::WeakMemFn<const R (C::*)()>::ResultType>::value));

// volatile R -> mwcu::WeakMemFnResult<volatile R>
ASSERT((bsl::is_same<
mwcu::WeakMemFnResult<volatile R>,
mwcu::WeakMemFn<volatile R (C::*)()>::ResultType>::value));

// const volatile R -> mwcu::WeakMemFnResult<const volatile R>
ASSERT((bsl::is_same<
mwcu::WeakMemFnResult<const volatile R>,
mwcu::WeakMemFn<const volatile R (C::*)()>::ResultType>::value));

// R& -> mwcu::WeakMemFnResult<R&>
ASSERT((bsl::is_same<mwcu::WeakMemFnResult<R&>,
mwcu::WeakMemFn<R& (C::*)()>::ResultType>::value));
Expand Down Expand Up @@ -244,16 +234,6 @@ static void test3_weakMemFnInstance_resultType()
mwcu::WeakMemFnResult<const R>,
mwcu::WeakMemFnInstance<const R (C::*)()>::ResultType>::value));

// volatile R -> mwcu::WeakMemFnResult<volatile R>
ASSERT((bsl::is_same<
mwcu::WeakMemFnResult<volatile R>,
mwcu::WeakMemFnInstance<volatile R (C::*)()>::ResultType>::value));

// const volatile R -> mwcu::WeakMemFnResult<const volatile R>
ASSERT((bsl::is_same<mwcu::WeakMemFnResult<const volatile R>,
mwcu::WeakMemFnInstance<const volatile R (
C::*)()>::ResultType>::value));

// R& -> mwcu::WeakMemFnResult<R&>
ASSERT((bsl::is_same<
mwcu::WeakMemFnResult<R&>,
Expand Down

0 comments on commit 9a10c65

Please sign in to comment.