Segfault on simple C code

Jeff Chimene jchimene@gmail.com
Sat Mar 7 07:30:00 GMT 2009


Hi,

I'm trying to run atlast using gcc:

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.3-3' 
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs 
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc 
--enable-mpfr --enable-targets=all --enable-cld --with-tune=generic 
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu 
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Debian 4.3.3-3)

The compilation succeeds. The original source is unchanged but for 
adding some includes.
cc -g      -c -o atlast.o atlast.c
cc -g      -c -o atlmain.o atlmain.c
cc -g    atlast.o atlmain.o -o atlast -lm

Why is the following line segfaulting? What changes are required to the 
source or command line?
    *(dw->wname) |= WORDUSED;

Where WORDUSED is defined as:
#define WORDUSED    2              /* Word used by program */

Where dw is defined as:
typedef struct dw {
    struct dw *wnext;              /* Next word in dictionary */
    char *wname;              /* Word name.  The first character is 
actually the word flags, including the (IMMEDIATE) bit. */
    codeptr wcode;              /* Machine code implementation */
} dictword;

tia,
jec



More information about the Gcc-help mailing list