On Wed, 2011-08-17 at 11:39 -0400, Andrew MacLeod wrote:
> Turns out, C++ will allow you to specify the memory model as a variable 
> of type enum memory_order... WTF?  I would expect that to be pretty 
> uncommon, and in order to get that right, we'd need a switch statement 
> and call the appropriate __sync_mem* routine with the appropriate 
> constant parameter.
> 
> That would be quite ugly, and you get what you deserve if you do that.   
> I changed the builtins so that if you dont specify a compile time 
> constant in the memory model parameter, it will simply default to 
> __SYNC_MEM_SEQ_CST, which will always be safe.  That is standard 
> compliant (verified), and if anyone is really unhappy about it, then the 
> c++ headers can be really uglified by adding a bunch of switch 
> statements to handle this twisted case.

IMHO this behavior should be documented so that users will be aware of
it, and it would be best if this would raise a warning. Note that I also
cannot see any reason why a programmer might want to make barriers
runtime-configurable, but silently adding overhead (perhaps the
parameter was supposed to be a constant, but wasn't?) can lead to more
confusion than necessary.

Torvald

Reply via email to