title: Accessing a static volatile variable from a thread
body: <p>I have a class that has declared a static volatile QHash</p>
  
  <pre><code>class Sample
  {
      volatile static QHash &lt;string, int&gt; myDict;
  }
  </code></pre>
  
  <p>And I am using a class to override the run() method of QThread</p>
  
  <pre><code>class MyThread : public QThread
  {
  public:
      void run()
      {
          string s = "hello";
          if(Sample::myDict.contains(s)){std::cout &lt;&lt; "i contain "&lt;&lt; s;}
      }
  }
  </code></pre>
  
  <p>But doing this gives me a compilation error : </p>
  
  <pre><code>passing 'volatile QHash&lt;std::string, int&gt;' as 'this' argument of 'bool QHash&lt;Key, T&gt;::contains(const Key&amp;) const [with Key = std::string; T = int]' discards qualifiers [-fpermissive]
  </code></pre>
  
  <p>So I checked on stack overflow. It seems that passing volatile variables to functions makes the compiler give a warning because compiler can do thread unsafe optimizations w.r.t that variable. But in my case, the compiler is giving an error instead of a warning. Also, here the volatile QHash seems to be an implicit argument to the function "QHash::contains".
  Any help? </p>