# A compiler flag to enforce precise lifetimes everywhere?

**URL:** <https://forums.swift.org/t/a-compiler-flag-to-enforce-precise-lifetimes-everywhere/37094>\
**Category:** Discussion\
**Tags:** lifetime\
**Created:** [June 1, 2020, 4:27am UTC](https://forums.swift.org/t/a-compiler-flag-to-enforce-precise-lifetimes-everywhere/37094 "2020-06-01T04:27:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serendipity](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Serendipity](https://forums.swift.org/u/Serendipity)\
**Post date:** [June 1, 2020, 4:27am UTC](https://forums.swift.org/t/a-compiler-flag-to-enforce-precise-lifetimes-everywhere/37094/1 "2020-06-01T04:27:51Z")

</div>

Hello folks,

Can we consider a compiler flag to enforce [_precise lifetimes_](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#precise-lifetime-semantics) by default everywhere? (including local variables)

Maybe there gonna make some performance impact, but imprecise-by-default for local variables needs too much attention to write correct programs. And I believe default behavior should be tuned for safety (which also implies correctness) first. Just like `-ffast-math` option. You get safet and correct by default and take the benefit only if you fully understand and can afford the trade off.

I discovered this while I was [digging into a bug](https://forums.swift.org/t/an-unexpected-deadlock-with-combine-only-on-release-build/37018/15). Thanks to nice folks here, I could resolve the issue. But I still think this is too much surprise as this is quite hard to figure out and makes writing correct programs in Swift far more difficult. And AFAIK, ease of use is also one of important goal of Swift.
