title: Calling a const function rather than its non-const version
body: <p>I tried to wrap something similar to Qt's shared data pointers for my purposes, and upon testing I found out that when the const function should be called, its non-const version was chosen instead.</p>
  
  <p>I'm compiling with C++0x options, and here is a minimal code:</p>
  
  <pre><code>struct Data {
      int x() const {
          return 1;
      }
  };
  
  template &lt;class T&gt;
  struct container
  {
      container() {
          ptr = new T();
      }
  
  
      T &amp; operator*() {
          puts("non const data ptr");
          return *ptr;
      }
  
      T * operator-&gt;() {
          puts("non const data ptr");
          return ptr;
      }
  
      const T &amp; operator*() const {
          puts("const data ptr");
          return *ptr;
      }
  
      const T * operator-&gt;() const {
          puts("const data ptr");
          return ptr;
      }
  
      T* ptr;
  };
  
  typedef container&lt;Data&gt; testType;
  
  void testing() {
      testType test;
      test-&gt;x();
  }
  </code></pre>
  
  <p>As you can see, Data.x is a const function, so the operator -> called should be the const one. And when I comment out the non-const one, it compiles without errors, so it's possible. Yet my terminal prints:</p>
  
  <blockquote>
    <p>"non const data ptr"</p>
  </blockquote>
  
  <p>Is it a GCC bug (I have 4.5.2), or is there something I'm missing? </p>