www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/27/14:18:04

From: Mark DOT Koennecke AT psi DOT ch
Subject: BUG in function parameter passing ??????
27 Aug 1998 14:18:04 -0700 :
Message-ID: <98082711213612.cygnus.gnu-win32@psicla.psi.ch>
To: GNU-WIN32 AT cygnus DOT com

  /*
    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 DOT Koennecke AT psi DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019