You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
switch_enum_addr was being treated like a store instruction, which killed
the local enum's liveness. This could result local variable analysis reporting a
shorter lifetime for the local.
This showed up as a missing exclusivity diagnostic because an access scope was
not fully extended across a dependent local variable of Optional type.
This prevents the following pattern from miscompiling. It should report an exclusivity violation:
var mutableView = getOpaqueOptionalView(holder: &holder)!
mutate(&holder)
mutableView.modify()
Fixes rdar://151231236 ([~Escapable] Missing 'overlapping acceses' error when
called from client code, but exact same code produces error in same module)
(cherry picked from commit fe9c0dd)
// Return an address-only optional view (requiring switch_enum_addr).
263
+
@_silgen_name("addressOnlyMutableView")
264
+
@_lifetime(&holder)
265
+
func addressOnlyMutableView<T>(holder:inoutHolder, with t:T)->AddressOnlyMutableView<T>?
266
+
267
+
// rdar://151231236 ([~Escapable] Missing 'overlapping acceses' error when called from client code, but exact same code
268
+
// produces error in same module)
269
+
//
270
+
// Extend the access scope for &holder across the switch_enum_addr required to unwrap Optional<AddressOnlyMutableView>.
271
+
func testSwitchAddr<T>(holder:inoutHolder, t:T){
272
+
// mutableView must be a 'var' to require local variable data flow.
273
+
varmutableView=addressOnlyMutableView(holder:&holder, with: t)! // expected-error {{overlapping accesses to 'holder', but modification requires exclusive access; consider copying to a local variable}}
274
+
mutate(&holder) // expected-note {{conflicting access is here}}
0 commit comments