On Sun, 6 Jun 1999, Marc Tardif wrote:

> The following code should obviously segfault:

Nope.  There is no requirement that code segfault.  C does not make any
promises that accessing memory that you have not allocated will do
anything.

> #include <stdio.h>
> #include <syslog.h>
> 
> char buffer[4028];
> 
> void main() {
>       int i;
>       for (i=0; i<=4028; i++)
>               buffer[i]='A';
>       syslog(LOG_ERR, buffer);
> }
> 
> Now here's the problem:
> When compiling with "gcc file.c", the program segfaults.
> When compiling with "gcc -o file file.c", the program doesn't segfault.

Try renaming a.out to file.  You will probably find it is due to the
length of the filename, since ARGV[0] is used by syslog.  



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to