<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, 15 Jan 2026 at 19:50, Ryan P. Nicholl &lt;<a href="mailto:rnicholl@protonmail.com">rnicholl@protonmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px">The implementation of std::atomic_notify_* on libc++, gcc, musl and microsoft STL is already in compliance with the proposed wording change.<br></div></blockquote><div><br></div><div>Your wording talks about a &quot;pointer to M&quot; but if M is outside its lifetime, then it&#39;s an invalid pointer value. You would need to talk about a pointer to the storage of M, otherwise your wording doesn&#39;t achieve what you want.</div><div><br></div><div>You never replied to my question about what it means if the memory has been deallocated and is not even part of the address space. Linux&#39;s futex(2) and FreeBSD&#39;s _umtx_op should return EFAULT for that, but your proposal says waiters might be spuriously unblocked, it doesn&#39;t allow a waiting operation to fail (potentially terminating, depending how the implementation handles errors from the system call). If the storage has already been reused for another atomic of a different type, worse things can happen than spuriously unblocking waits on the new object: macOS will return EINVAL if the wake and wait calls don&#39;t agree on the size of the value at that address.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px"><br>They are <b>already</b> fully implemented, this proposal would only be a standardese fix. You cannot tell me this is not possible to do, it is already done. I can write code that will work fine on all platforms, but according to the standard C++ language it&#39;s not allowed. <b>AFAIK, all platforms already do this.</b> If you know an implementation that doesn&#39;t do this with std::atomic_notify_*, I would like to know what that is.</div></blockquote><div><br></div><div>GCC&#39;s implementation immediately dereferences the pointer parameter of atomic_notify_one, which is undefined if the std::atomic object is outside its lifetime. It would also not be valid in a constant expression, but that function is constexpr now, so you need to consider what should happen there. Changing those properties of the implementation wouldn&#39;t be difficult if needed, but it&#39;s not true that they already implement what you want. It&#39;s only true if you say that what is undefined in the abstract machine is fine, because it happens to work.</div><div><br></div><div>Within the implementation of __atomic_wait_address there are operations such as casts and lvalue-to-rvalue conversions which are implementation-defined if the pointer is an invalid pointer value, such as a pointer to a region of storage that no longer contains an object. </div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px"> Saying &quot;this can&#39;t be done&quot; without doing any investigation on your own is not that productive.</div></blockquote><div><br></div><div>Saying &quot;this can be done&quot; when you&#39;re talking about requiring operations on invalid pointer values outside of an object&#39;s lifetime is just brushing aside a lot of rules of the abstract machine. Again, you opened the entire discussion talking about the abstract machine, but the proposal is basically requiring atomic_notify_one to operate entirely outside the abstract machine, treating its parameter as an opaque pattern of bits with no relation to an object (it&#39;s hard to interpret the wording any other way if the calls are allowed invalid pointer values as arguments, or can race with destructors of the object).</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px">There are certainly some OS where you can&#39;t directly wait on the atomic address itself if the wait area is larger than the atomic region, using a <b>single</b> system call, that doesn&#39;t mean it isn&#39;t possible to do using another algorithm, though. As it turns out, address monitor queues work for an arbitrarily sized type. Is it a bit slower? Yes. Is it unimplementable? No. Do all atomic implementations use monitor queues for types that don&#39;t fit in the os sync primitives? As far as I can tell, yes. And of course, even lock based atomics work fine with monitor queues too, so I see no reason not to allow it. If you can wait on any value of any size, you can create a monitor queue for values of arbitrary sizes.</div><br></blockquote></div></div>

