This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

BUG in function parameter passing ??????


  /*
    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:
               Mark.Koennecke@psi.ch
     
    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
"gnu-win32-request@cygnus.com" with one line of text: "help".


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