I can print a string with printf("%s", str) but strlen(str) in the next statement fails with Segment fault.
$ gcc -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --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-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) "gcc -g soundex.c -S" gives the following assembler for the 2 calls: .loc 1 57 0 movl stderr, %edx movl 8(%ebp), %eax movl %eax, 8(%esp) movl $.LC7, 4(%esp) movl %edx, (%esp) call fprintf .loc 1 58 0 movl 8(%ebp), %eax movl %eax, (%esp) call strlen addl 8(%ebp), %eax movl %eax, 12(%ebp) "gcc -O3 -fomit-frame-pointer soundex.c -S" gives: movl stderr, %eax movl %esi, 12(%esp) movl $.LC0, 8(%esp) movl $1, 4(%esp) movl %eax, (%esp) call __fprintf_chk movl %esi, (%esp) call strlen leal (%esi,%eax), %edi Strangely, this optimised code works fine. -- Summary: strlen() crashes with sigsegv on ubuntu 8.10 Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ajrobb at bigfoot dot com GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39166