-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Lines 1240 to 1246 in f9b1dcc
| void set_value(_Ty& _Val) { | |
| _MyPromise._Get_state_for_set()._Set_value(&_Val, false); | |
| } | |
| void set_value_at_thread_exit(_Ty& _Val) { | |
| _MyPromise._Get_state_for_set()._Set_value(&_Val, true); | |
| } |
This code is saying &_Val to get the address of an object (specifically, a parameter passed by reference). This is, perhaps surprisingly, a bug. The STL is required to be extremely flexible and work with near-arbitrary user-defined types. In particular, user-defined types might overload the address-of operator, operator&(), and the STL is required to tolerate this.
We do so by calling the library function addressof(), which uses special magic to get the true address of an object without interference from overloaded operators.
Additionally, the STL is required to defend itself against Argument-Dependent Lookup, so we explicitly qualify all non-_Ugly function calls. We use an internal macro for this: _STD expands to ::std:: .
This should be a two-line fix (unless I have missed other occurrences; note that it is okay to say &thing for object types that can't depend on user-defined types - there's no way that &some_int can misbehave).