🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6005

Re: gcc 2.7.2 problem with strtok()

#6005
From: M.Wang
Date: Fri, 27 Dec 1996 00:00
24 lines
1082 bytes
Alain Magloire <alainm@macs.ee.mcgill.ca> wrote:

: strtok("a b c", " ");

>"a b c" is a __string constant__ i.e non-writable
>strtok() will modify it hence the coredump
>try
>char string[10] = "a b c";
>strtok(string, " ");

I tend to agree what you said and what you suggested indeed solved 
the problem. I just want to point put the SUN's c compiler does not
have problem with

strtok("a b c", " ");

OR

char *p;
p="a b c";
strtok(p, " ");

But gcc does generate coredump. Why is this? Thanks. 
Technical Details
Message-ID: <5a0vsc$ap0@nntpb.cb.lucent.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <59vbmi$9i0@nntpb.cb.lucent.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,18b9f2c0ce00f3
X-Google-Attributes: gid113d02,public
From: xiaofei@lucent.com (M.Wang)
Subject: Re: gcc 2.7.2 problem with strtok()
Date: 1996/12/27
Message-ID: <5a0vsc$ap0@nntpb.cb.lucent.com>
X-Deja-AN: 206241722
sender: bug-gcc-request@prep.ai.mit.edu
references: <59vbmi$9i0@nntpb.cb.lucent.com>
organization: AT&T
original-from: mwang@fuwutai.wh.lucent.com (M.Wang)
x-gateway: relay3.UU.NET from bug-gcc to gnu.gcc.bug; Fri, 27 Dec 1996 12:10:07 EST
newsgroups: gnu.gcc.bug