title: Segmentation fault when passing function pointer
body: <p>I am using Solaris. The code where i am getting segmentation fault is inside .so .We have few static functions, basically these functions are callback functions. I set these functions as callback functions by passing its address to another function. Only for one of the function its address before passing as an argument looks correct , but after stepping into the function to set the function pointer, it changed into some junk pointer and calling the function by that pointer crashes.
  I am putting some sample code, its not the actual  code, but it is similar to that.</p>
  
  <p>In A.cpp, i have three callback functions</p>
  
  <pre><code>static void Func1(A* ptr)
  {
  }
  
  static void Func2(A* ptr)
  {
  }
  
  static void Func3(A* ptr)
  {
  }
  </code></pre>
  
  <p>In one register function, i assign these as callback functions</p>
  
  <pre><code>void vRegisterCallback(void (*ptrToFunc)(void*))
  {
  }
  
  void Register()
  {
      vRegisterCallback(void (*)(void*)Func1);
      vRegisterCallback(void (*)(void*)Func2);
      vRegisterCallback(void (*)(void*)Func3);
  }
  </code></pre>
  
  <p>I register three function as like above.<br>
  <code>Func1</code> pointer is valid, but when it is passed as an argument to <code>vRegisterCallback</code>.  <code>vRegisterCallback</code> is having different address than <code>Func1</code>.</p>
  
  <p>If I add a <code>printf</code> statement above it works with valid pointer sent to <code>vRegisterCallback</code>.<br>
  If I change the <code>Func1</code> from static to non static it works...<br>
  If I change the .so to .a , it works.</p>
  
  <p>Dont know what is the problem.</p>