This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Q: Sibling calls


Hi!

With the new patch for sibcalls on sparc this program with void
functions works fine: 

  +void one(int x);
  +void two(int x);
  +
  +int main(void)
  +{
  +    one(0);
  +}
  +
  +void one(int x)
  +{
  +    printf("one %i\n",x);
  +    two(x+1);
  +} 
  +
  +void two(int x)
  +{
  +    printf("two %i\n",x);
  +    one(x+1);
  +}


But why doesn't this one work? It causes a segmentation fault.

  +int main(void) 
  +{
  +    one(0);
  +}
  +
  +int one(int x)
  +{
  +    printf("one %i\n",x);
  +    two(x+1);
  +}
  +
  +int two(int x)
  +{
  +    printf("two %i\n",x);
  +    one(x+1);
  +}


Regards,
Peter and Anders

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]