This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15984] New: Different behavior of gcc when passing hard/variable argument
- From: "pierre-matthieu dot anglade at cea dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jun 2004 12:12:05 -0000
- Subject: [Bug c/15984] New: Different behavior of gcc when passing hard/variable argument
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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