Re: I'm sorry...



As to why it worked on SunOS and IRIX, SunOS and Solaris have been known
for being very forgiving with memory access violations that should be
prevented while Linux is in general very unforgiving and appropriately
segfaults.  This is a case where as people have stated, you are
potentially illegally accessing read-only memory with a write and Linux is
behaving properly.  I would guess that IRIX would be just as forgiving as
SunOS/Solaris.  This is probably why SunOS and IRIX didn't puke like
Linux.  However, whenever you have constant literal strings you should
always think twice before altering them.  :)

Just my 2 pence.  :)

--Jason

On Mon, 30 Nov 1998 sml13@cornell.edu wrote:

> ...to abuse the list like this (this will be the only time, I promise), 
> but can any of you GCC/C hackers out there tell me why Gcc (2.7.2.3 on 
> Linux x86) segfaults on execution of this program:
> 
> #include <stdio.h>
> #include <string.h>
> 
> void main() {
>     printf ("%s\n", strtok ("hey you", " "));
> }
> 
> This is a correct usage of strtok, from what I have read.  I am trying to 
> use this function in a project, but it segfaults every time.  It is 
> standard ANSI C.  And, even weirder, I have gotten it to work on SunOS 
> and IRIX systems using the cc that comes with the computer.  Is Gcc's 
> implementation of strtok busted? (I highly dout it...but what am I doing 
> wrong?)
> 
> shane
> 
> 
> -- 
>         FAQ: Frequently-Asked Questions at http://www.gnome.org/gnomefaq
>          To unsubscribe: mail gnome-list-request@gnome.org with 
>                        "unsubscribe" as the Subject.
> 
> 

----  
 Jason A. Pfeil                               pfeil@cs.fsu.edu 
 Information Systems Developer                jpfeil@lsi.fsu.edu
 CASDL                                        (850)644-8014; fax: (850)644-4952
 Learning Systems Institute                   University Center C-3527
 http://idl.fsu.edu                           Tallahassee, FL  32306-2540



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]