title: Segfault while using transactional memory, tried to implement golang's chan analog
body: <p>My code is following,logic is readable,i'm not sure about atomic's,it's compile without even warning's,but i get segfault's again and again</p>
  
  <pre><code>#include &lt;atomic&gt;
  //#include &lt;mutex&gt;
  #include &lt;memory&gt;
  //#include &lt;math.h&gt;
  //#include &lt;optional&gt;
  #include &lt;utility&gt;
  
  using namespace std;
  
  namespace tema2 {
  template &lt;class T,size_t A&gt;
  class fl_chan {
  public:
      fl_chan(){
          //long unsigned int zero = 0;
          place_st.store(0);
          take_st.store(0);
          delta.store(0);
          return;
      };
      bool recv(T &amp;trg){
          synchronized {
              synchronized {
                  if (take_st == A){
                      take_st.store(0);
                  }
              }
              if (delta == 0){
                  return false;
              }
  
              T var = T();
              swap(var,data[take_st++]);
              trg = var;
              --delta;
              return true;
          }
      }
      bool send(T arg){
          synchronized {
              synchronized {
                  if (place_st == A){
                      place_st.store(0);
                  }
              }
              data[place_st++]=arg;
              ++delta;
              return true;
          }
      }
  
  private:
      T data[A];
      atomic&lt;uint64_t&gt; place_st;
      atomic&lt;uint64_t&gt; take_st;
      atomic&lt;uint64_t&gt; delta;
  };
  
  
  };
  </code></pre>
  
  <p></p>