public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/15984] New: Different behavior of gcc when passing hard/variable argument
@ 2004-06-14 12:12 pierre-matthieu dot anglade at cea dot fr
2004-06-14 12:23 ` [Bug c/15984] " amodra at bigpond dot net dot au
0 siblings, 1 reply; 2+ messages in thread
From: pierre-matthieu dot anglade at cea dot fr @ 2004-06-14 12:12 UTC (permalink / raw)
To: gcc-bugs
The code enclosed don't work with gcc. The second fonction call result in a
segmentation fault. It seems to be a bug. Compilers from unix vendors (all but
IBM) works fine on this. (please see below for arch details)
-------------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
void cut (char *);
int
main(void)
{
char str1[1000];
sprintf(str1,"bv 10 12 14 13 345 56 56 xfg");
cut(str1);
cut("bv 10 12 14 13 345 56 56 xfg");
return 0;
}
void
cut(char *str){
char *token;
//fprintf(stderr,"arg adress:%p\n",str);
token = strtok(str,";, \t...whatever you want");
do{
fprintf(stderr,"%s\n",token);
}while( (char *)NULL != (token=strtok((char *)NULL,";, \t...whatever you want"
)));
}
________________________________________________________________________________
It seems that gcc is using a different way for representation in memory of
the argument str1 and the constant argument.
*ARCH:
i686, sparc, power4, PA-RISC, alpha, MIPS, power3.
*GCC version:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib
--enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
ou:
Reading specs from
/usr/local/gnu/bin/../lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs
Configured with: ../../../src/gcc-3.2.1/configure
--prefix=/usr/local/rep/gcc-3.2.1
--exec-prefix=/usr/local/rep/gcc-3.2.1/SunOS_5.8 --enable-languages=c++,f77,java
Thread model: posix
gcc version 3.2.1
ou: .... (down to v2.95 at least)
--
Summary: Different behavior of gcc when passing hard/variable
argument
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pierre-matthieu dot anglade at cea dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: gcc
GCC host triplet: sparc/solaris
GCC target triplet: inluded in description
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15984
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/15984] Different behavior of gcc when passing hard/variable argument
2004-06-14 12:12 [Bug c/15984] New: Different behavior of gcc when passing hard/variable argument pierre-matthieu dot anglade at cea dot fr
@ 2004-06-14 12:23 ` amodra at bigpond dot net dot au
0 siblings, 0 replies; 2+ messages in thread
From: amodra at bigpond dot net dot au @ 2004-06-14 12:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2004-06-14 12:23 -------
strtok modifies its first argument. If you can't rewrite your buggy program,
-fwritable-strings might help.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15984
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-14 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-14 12:12 [Bug c/15984] New: Different behavior of gcc when passing hard/variable argument pierre-matthieu dot anglade at cea dot fr
2004-06-14 12:23 ` [Bug c/15984] " amodra at bigpond dot net dot au
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).