On 08/19/2011 12:48 PM, Torvald Riegel wrote:

The problem with issuing a warning is that anytime the compiler creates
a C++ atomic class and you use a method with a memory order, it usually
leaves an externally call-able method which has to take a runtime
value... so you'd see the warning on basically every compilation...
which in turn defeats the purpose of the warning.
Hmm. I would have assumed that the check that would raise warnings would
be for actual calls, not for the instantiations. But that would probably
require special handling of calls to the atomics class for all the
integers and pointers (can atomic<T*>  be handled as one thing?). So, if
that's too much work, at least document the constraint somewhere?


I'd definitely document the constraint.

To be honest, I think its a pretty useless thing, bordering on moronic. The whole point of the memory model is to be able to generate more efficient code when you don't need SEQ_CST and really know what you are doing.

Even if you *DO* want to make that kind of a call, you have to expect the overhead of a runtime library call. And if you are using SEQ_CST mode, its going to be that much slower again due to the call. I think inlining it to be SEQ_CST will provide smaller code size always, and I'd be surpised if it *ever* became a performance issue. And I do mean *ever*.

Andrew

Reply via email to