Article View: gnu.gcc.bug
Article #6007Re: gcc 2.7.2 problem with strtok()
From: Alain Magloire
Date: Sat, 28 Dec 1996 00:00
Date: Sat, 28 Dec 1996 00:00
46 lines
1674 bytes
1674 bytes
M.Wang (xiaofei@lucent.com) wrote:
: Alain Magloire <alainm@macs.ee.mcgill.ca> wrote:
: : strtok("a b c", " ");
: >"a b c" is a __string constant__ i.e non-writable
: 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.
#ifdef OFF_TOPIC
First, sorry for posting twice :-(
I was diverted for a moment and forgot that
I had already post.
#endif
Well this another issue !! I was assuming that your
compiler was gcc ...ANSI-C ;-)
[anybody with more info, please feel free to correct me]
SunOS (bundle) cc .. K&R .... hmm..
The location of a constant string
is compiler dependent. Old compilers like
bundle cc from SunOS tends to put them
in the data area.
So the code will run ok with cc .. but not portable
ANSI C compiler (gcc) will put constant strings in
the text area (Read Only Mem.)
--
Bonne anne'e, alain
Technical Details
Message-ID:
<5a1o0h$8lj@sifon.cc.mcgill.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<5a0vsc$ap0@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: alainm@macs.ee.mcgill.ca (Alain Magloire) Subject: Re: gcc 2.7.2 problem with strtok() Date: 1996/12/28 Message-ID: <5a1o0h$8lj@sifon.cc.mcgill.ca> X-Deja-AN: 206291503 sender: bug-gcc-request@prep.ai.mit.edu references: <5a0vsc$ap0@nntpb.cb.lucent.com> organization: McGill University - MACS Laboratory, Montreal, CANADA. x-gateway: relay7.UU.NET from bug-gcc to gnu.gcc.bug; Fri, 27 Dec 1996 19:01:45 EST newsgroups: gnu.gcc.bug