Subject: BUG in function parameter passing ??????
From: [email-masked]

27 Aug 1998 14:18:04 -0700
Message-ID: <[email-masked]>
To: [email-masked]

  /*
    This is a little C program which demonstrates a little problem 
    with CYGNUS32. This code works fine on a DigitalUnix, but breaks under
    Cygwin. I do not know if it is a cygwin problem or if it is a C problem.
    The symptom is a segmentation violation in strtolower.
    The SEGVIOL is always at the tolower. I found that tolower does not
    matter, what matters is that I want to change the value of the string
    passed in. 

    If it is a real problem and not my bad understanding of C then it must
    have to do with the way parameters are allocated on the stack when
    calling a function. This sounds like very deep in the belly of cygwin or
    the gcc compiler.
    
    Please mail your ideas to:
               [email-masked]
     
    Please mail, as I do not monitor this mailing list due to time constraints
    and my irregular use of the Cygwin tools. I almost forgot: the version
    is Cygwinb19.1 on a Windows-NT workstation 4.0 with a Pentium.            
  */             

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
/*---------------------------------------------------------------------------*/
  void strtolower(char *pText)
  {
    int i;
    char *pPtr;
    
    assert(pText);
    
    for(i = 0, pPtr = pText; i < strlen(pText); i++, pPtr++)
    {
      *pPtr = tolower(*pPtr);
    }
  }
/*---------------------------------------------------------------------*/

int main(int argc, char *argv[])
{
  char pBuffer[132];
  
  /* why does this work? */
  strcpy(pBuffer,"Hello You");
  strtolower(pBuffer);
  
  /* but this gives a segmentation violation under Cygwin*/
  strtolower("Hello You");
  
  printf("Success\n");
  
}
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".