This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc runtime error in version 2.8.1 and 2.9.5
- To: gcc-bugs at gcc dot gnu dot org
- Subject: gcc runtime error in version 2.8.1 and 2.9.5
- From: Tom Warsinske <twarsins at orchard dot wccnet dot org>
- Date: Thu, 11 May 2000 12:26:07 -0400
- CC: admins at orchard dot wccnet dot org
- Organization: Washtenaw Community College
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