Sujet : Re: Strange asm generated by GCC...
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.archDate : 20. Dec 2024, 02:02:39
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vk2fnf$33q08$3@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 12/19/2024 4:43 PM, Chris M. Thomasson wrote:
Why in the world would GCC use an XCHG instruction for the following code. The damn XCHG has an implied LOCK prefix! Yikes!
https://godbolt.org/z/Thxchdcr8
_______________________
#include <atomic>
int main()
{
std::atomic<unsigned long> m_state = 0;
m_state.store(std::memory_order_relaxed);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Strange to me that this even compiled at all. I clearly forgot to put in a value. aka:
m_state.store(1, std::memory_order_release);
Sorry about that. ;^o
DOH!!!!!
return 0;
}
_______________________
[...]