Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Feb 1998 15:25:03 -0500
From:      Brian Reichert <reichert@numachi.com>
To:        hackers@FreeBSD.ORG
Cc:        stt@pluto.cpe.ku.ac.th
Subject:   Signal 11 problem
Message-ID:  <19980222152502.06434@numachi.com>

next in thread | raw e-mail | index | archive | help
Return-Path: <reichert@mail.numachi.com>
Received: (qmail 12473 invoked by uid 1001); 22 Feb 1998 20:21:51 -0000
Message-ID: <19980222152150.11604@numachi.com>
Date: Sun, 22 Feb 1998 15:21:50 -0500
From: Brian Reichert <reichert@numachi.com>
To: Sunthiti Patchararungruang <stt@pluto.cpe.ku.ac.th>
Subject: Re: Signal 11 problem
References: <Pine.BSF.3.96.980223003718.18247A-100000@pluto.cpe.ku.ac.th>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.88
In-Reply-To: <Pine.BSF.3.96.980223003718.18247A-100000@pluto.cpe.ku.ac.th>; from Sunthiti Patchararungruang on Mon, Feb 23, 1998 at 12:59:29AM +0700
Return-Receipt-To: reichert@numachi.com

On Mon, Feb 23, 1998 at 12:59:29AM +0700, Sunthiti Patchararungruang wrote:
> Dear Everybody,
> 
> 	I have written a C program which has a function that need 10
> arguments. I cannot run this program because the signal-11 occured when I
> call this function.

>       test (int, int, int, int, int, int, int, int, int, int, int)

> 	main ()
> 	{
> 		// Error Signal 11

I presume the C++ comment is a red herring. :)

> 		test (a, b, c, d, e, f, g, h, i, j, k);
> 	}

[...]

> 	main (
> 	{
> 		test (a, b, c, d, e);
> 		test (f, g, h, i, j);
> 		test (a, b, k, d, e);
> 	}

Well, you declared the function as using ten arguments, then you
only gave it five.  How does your function 'know' that it's only
been given five arguments?  If it tries to make use an argument
you didn't give it, it could easily leap off into nowhere...

If you were to build your code with gcc -Wall, it would warn you
about not handing in the right number of arguments...

If you're trying to write a function that handles a variable number
of arguments, look at stdarg(3).

> Best Regards,
> Sunthiti Patchararungruang

-- 
Brian Reichert			          		  reichert@numachi.com
Current daytime number: (617)-873-4337

37 Crystal Ave. #303
Derry NH 03038-1713 USA			Intel architecture: the left-hand path

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980222152502.06434>