From owner-freebsd-bugs Sat Mar 31 5:26:29 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from ns.smela.ldc.net (ldc-smela.ldc.net [213.160.128.218]) by hub.freebsd.org (Postfix) with ESMTP id 448F837B719 for ; Sat, 31 Mar 2001 05:26:20 -0800 (PST) (envelope-from vlaman@vlaman.smela.ldc.net) Received: from vlaman.smela.ldc.net (vlaman.smela.ldc.net [213.160.130.70]) by ns.smela.ldc.net (8.11.1/8.10.2) with ESMTP id f2VDPpP18158 for ; Sat, 31 Mar 2001 16:25:52 +0300 Received: from vlaman by vlaman.smela.ldc.net with local (Exim 3.20 #1) id 14jLOP-0000yy-00 for freebsd-bugs@freebsd.org; Sat, 31 Mar 2001 16:26:13 +0300 From: Vladimir Mandro To: freebsd-bugs@freebsd.org Subject: bug in gcc or my hands? Message-Id: Date: Sat, 31 Mar 2001 16:26:13 +0300 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hello! I discovered some strange gcc actions. Compiling program: ---begin of main.c--- void main() { char *s = "Hello"; *s=0; } ---end of main.c--- gcc -o exp1 main.c Executing: myhost@myhost$ ./exp1 Bus error (core dumped) Running gdb. Stepping through program. All works fine and program finishes succesfully. Running gdb again. Running program without breakpoints or stepping. Line *s=0 causes segmentation fault. OK. Replacing char *s = "Hello" with char s[] = "Hello". All works fine. Book "The C Programming Language" by Kernighan&Ritchie tells, that declaration char *s and char s[] are equivalent. Whats wrong? Thanks. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message