title: Warning: Initialization of 'UnsafeBufferPointer<T>' results in a dangling buffer pointer
body: <p>After update to Swift 5.2 / Xcode 11.4 got a warning to following code:</p>
  
  <pre class="lang-swift prettyprint-override"><code>extension Data {
  
      init&lt;T&gt;(from value: T) {
          var value = value
          let pointer = UnsafeBufferPointer(start: &amp;value, count: 1)
          self.init(buffer: pointer)
      }
  
      func to&lt;T&gt;(type: T.Type) -&gt; T {
          return self.withUnsafeBytes { $0.load(as: T.self) }
      }
  }
  </code></pre>
  
  <p>On line <strong>let pointer = UnsafeBufferPointer(start: &amp;value, count: 1)</strong> I got </p>
  
  <blockquote>
    <p>Initialization of 'UnsafeBufferPointer' results in a dangling buffer pointer</p>
  </blockquote>
  
  <p>I can use @silenceWarning but it's dirty solution. Maybe I need to store pointer somewhere and clean it in the future? </p>