Boost logo

Boost :

Subject: [boost] [interprocess] Superfluous "volatile" in atomic_add_unless32
From: Capehart, Nolan (Nolan.Capehart_at_[hidden])
Date: 2010-07-29 15:44:57

In this:
  inline bool atomic_add_unless32(volatile boost::uint32_t *mem,
boost::uint32_t value, volatile boost::uint32_t unless_this) I think
"volatile" on the last argument has no purpose and probably reduces
speed slightly.

Will it not merely cause the compiler to fetch the formal argument from
memory every time it's needed? And isn't that of no use since nothing is
modifying the formal argument during the function execution?

  1) Caller puts actual argument on stack.
  2) Caller calls atomic_add_unless32.
  3) atomic_add_unless32 treats stack variable as volatile, wasting time
(not much) because variable isn't actually changing.

Boost list run by bdawes at, gregod at, cpdaniel at, john at