gcc runtime error in version 2.8.1 and 2.9.5
Tom Warsinske
twarsins@orchard.wccnet.org
Thu May 11 09:25:00 GMT 2000
Greetings,
The following test code produces a Segmentation Fault when compiled with
gcc 2.8.1 on Solaris 2.5.1 and with gcc 2.9.5 on Solaris 2.7. The
program executes correctly when compiled with Sun's cc: WorkShop
Compilers 4.2 30 Oct 1996 C 4.2 on Solaris 2.5.1. Here is the test
program --
++++++++++++++++++++++++
#include <stdio.h>
#include <strings.h>
char *rtrim(char *, char );
int main() {
char *lname = "MOUSExxxx";
char *fname = "MICKEY ";
lname = rtrim(lname,'x');
printf("%s \n",lname);
}
char *rtrim(char *str1, char c) {
char *s;
printf("%s \n",str1);
s = index(str1, c);
printf("%s \n",s);
*s = '\0'; <= causes segmentation fault
return(str1);
}
$a.out
MOUSExxxx
xxxx
Segmentation Fault
Cordially yours,
Tom Warsinske, DBA
Washtenaw Community College
Ann Arbor, MI
(734) 973-3654
More information about the Gcc-bugs
mailing list