title: Pedantic gcc warning: type qualifiers on function return type
body: <p>When I compiled my C++ code with GCC 4.3 for the first time, (after having compiled it successfully with no warnings on 4.1, 4.0, 3.4 with the <code>-Wall -Wextra</code> options) I suddenly got a bunch of errors of the form <code>warning: type qualifiers ignored on function return type</code>.</p>
  
  <p>Consider <code>temp.cpp</code>:</p>
  
  <pre><code>class Something
  {
  public:
      const int getConstThing() const {
          return _cMyInt;
      }
      const int getNonconstThing() const {
          return _myInt;
      }
  
      const int&amp; getConstReference() const {
          return _myInt;
      }
      int&amp; getNonconstReference() {
          return _myInt;
      }
  
      void setInt(const int newValue) {
          _myInt = newValue;
      }
  
      Something() : _cMyInt( 3 ) {
          _myInt = 2;
      }
  private:
      const int _cMyInt;
      int _myInt;
  };
  </code></pre>
  
  <p>Running <code>g++ temp.cpp -Wextra -c -o blah.o</code>:</p>
  
  <pre><code>temp.cpp:4: warning: type qualifiers ignored on function return type
  temp.cpp:7: warning: type qualifiers ignored on function return type
  </code></pre>
  
  <p>Can someone tell me what I am doing wrong that violates the C++ standard? I suppose that when returning by value, the leading <code>const</code> is superfluous, but I'm having trouble understanding why it's necessary to generate a warning with it. Are there other places where I should leave off the const?</p>