hkaiser changed the topic of #ste||ar to: STE||AR: Systems Technology, Emergent Parallelism, and Algorithm Research | stellar-group.org | HPX: A cure for performance impaired parallel applications | github.com/STEllAR-GROUP/hpx | This channel is logged: irclog.cct.lsu.edu
<satacker[m]>
(the one you wanted me to go throught it)
<gonidelis[m]>
Yes!
<gonidelis[m]>
K-ballo: not being familiar with the correspondence between compilers and C++ versions what version of clang should I use to observe this behavior?
<gonidelis[m]>
"_Have you seen code that makes qualified calls to swap in a template, like std::swap( a, b ); ? Congratulation, you have probably found a bug_"
<gonidelis[m]>
clang 14 compiles just fine :)
<K-ballo>
if the types of a and b are dependent then it is indeed a bug
<K-ballo>
it won't usually cause a miscompilation though
<gonidelis[m]>
why no miscompilation?
<K-ballo>
it will do a fallback 3-moves swap
<K-ballo>
why do you expect a miscompilation to begin with?
<K-ballo>
the types of a and b are always `type_a_namespace::A<int>`
<K-ballo>
fwiw this kind of bug can happen without any templates involved (the quote is kinda weak or misguiding, unless there's more information in context)
<K-ballo>
is one of the main reasons CPOs were first designed
<K-ballo>
std::ranges::swap doesn't have that problem
<gonidelis[m]>
I fail to understand the engineering behind that 100%
<gonidelis[m]>
I do understand the effects
<gonidelis[m]>
Seems like I have to do something very very specific to trigger this bug
<K-ballo>
no, it's actually fairly straightforward
<K-ballo>
do you understand what the bug is?
<gonidelis[m]>
yes
<gonidelis[m]>
the overloaded swap is installed
<gonidelis[m]>
is invoked*
<K-ballo>
and why is that a bug?
<gonidelis[m]>
cause the user qualifies with `std::` so he wants the OG swap
<K-ballo>
og?
<gonidelis[m]>
original
<gonidelis[m]>
the standard library one
<K-ballo>
the bug is the user most likely does NOT want the standard library one
<K-ballo>
if the user does indeed want the standard library one, then it's perfectly fine to qualify std::swap
<K-ballo>
`swap` is a customization point, calling `std::swap` side-steps any customizations
<gonidelis[m]>
sorry yes that's what i meant
<gonidelis[m]>
i am dazzled
<gonidelis[m]>
no that i am thinking of
<gonidelis[m]>
isn't it user's fault that they call std::swap and yet they dont want std::swap?
<gonidelis[m]>
if `swap` was giving `std::swap` then that would be an understandable bug
<K-ballo>
the bug was created by whoever made a qualified call when they wanted the customizable one
<gonidelis[m]>
yes
<gonidelis[m]>
anyways... what's the way to trigger it then
<K-ballo>
call qualified std::swap on something that customizes swap
<K-ballo>
(something other than the standard library, which has special status)
<gonidelis[m]>
how do you customize swap is my question
<K-ballo>
define a swap function in an associated namespace of T