This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc solution


Greetings again,

I have just discovered the gcc "-fwritable-strings" compiler switch.  This effectively eliminated the problem which I submitted earlier.  My apologies.

-Tom Warsinske

++++++++++++++++++++++++++++++++++

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
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]