title: Is the const value parameter in definition but not declaration really C++?
body: <p>This is similar to (but different from) <a href="https://stackoverflow.com/questions/117293/use-of-const-for-function-parameters" title="tangent from this question">this question</a>.</p>
  
  <p>Here is some simple test code to illustrate some weirdness I have discovered with Sun CC:</p>
  
  <pre><code>//---------------main.cpp
  #include "wtc.hpp"
  
  int main(int, char**)
  {
    testy t;
    t.lame(99);
    return 0;
  }
  //--------------wtc.hpp
  #ifndef WTC_HPP_INCLUDED
  #define WTC_HPP_INCLUDED
  
  class testy
  {
  public:
    void lame(int );
  };
  
  #endif 
  
  //---------------wtc.cpp
  #include &lt;iostream&gt;
  #include "wtc.hpp"
  
  void testy::lame(const int a)
  {
    std::cout &lt;&lt; "I was passed " &lt;&lt; a &lt;&lt; "\n";
  }
  
  //---------------makefile
  #CXX=CC
  CXX =g++
  #CXXFLAGS= -g 
  CXXFLAGS= -g3 -Wall -Werror
  
  OBJECTS=$(patsubst %.cpp,%.o,$(wildcard *.cpp))
  
  all : $(OBJECTS)
      $(CXX) $(CXXFLAGS) -o $@ $^
  
  .PHONY: clean
  clean :
      rm *.o
  </code></pre>
  
  <p>When this was compiled using g++ it compiles, links and does what you would expect when run.
  You can also add a ++a; in testy::lame()  and the compiler will complain about changing a read-only variable (as it should).</p>
  
  <p>However when I compile using CC,  I get the following linker error:</p>
  
  <pre><code>CC -g   -c -o main.o main.cpp
  CC -g   -c -o wtc.o wtc.cpp
  CC -g -o all main.o wtc.o
  Undefined                       first referenced
   symbol                             in file
  void testy::lame(int)               main.o
  ld: fatal: Symbol referencing errors. No output written to all
  make: *** [all] Error 1
  </code></pre>
  
  <p>checking the object code with nm and C++filt, I find that the g++ version creates a 
  testy::lame(int)  symbol,  whereas  CC creates  testy::lame(const int) , hence the linker error.</p>
  
  <p>I looked it up in Stroustrup's book, but can't find this technique mentioned (doesn't mean it's not there!); so is this really a compiler bug, or just a hack that works everywhere else but Solaris? </p>