From bug-octave-request at bevo dot che dot wisc dot edu Fri Oct 27 11:42:37 2000 Subject: all_va_args bug? From: "John W. Eaton" To: Etienne Grossmann Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 27 Oct 2000 11:42:17 -0500 On 27-Oct-2000, Etienne Grossmann wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: etienne | Subject: all_va_args bug? | | Bug report for Octave 2.1.31 configured for %OCTAVE_CANONICAL_HOST_TYPE% | | Description: | ----------- | | all_va_args panics octave when no optional args are present. | | Repeat-By: | --------- | | octave:1> function bar (f,x,...) feval (f,x, all_va_args); end | octave:2> function foo (x,y) printf ("Received %i args\n",nargin); end | octave:3> function fo2 (...) printf ("Received %i args\n",nargin); end | octave:4> bar ("fo2",12) | octave: parse.y:3290: class octave_value_list feval(const octave_value_list &, int): Assertion `arg_names.length () == tmp_nargin + 1' failed. | panic: Aborted -- stopping myself... | attempting to save variables to `octave-core'... | save to `octave-core' complete | Aborted | | bar ("foo",12) causes the same | bar ("fo2",12,13,14) causes the same | bar ("fo0",12,13,14) causes the same | | bar ("foo",12,13) works ok | bar ("fo2",12,13) works ok Please try the following patch (your line numbers may be different). Thanks, jwe 2000-10-27 John W. Eaton * parse.y (feval (const octave_value_list&, int)): Don't panic while processing arg names if arg.length() and arg_names.length() differ. Index: parse.y =================================================================== RCS file: /usr/local/cvsroot/octave/src/parse.y,v retrieving revision 1.161 diff -c -r1.161 parse.y *** parse.y 2000/08/22 06:21:21 1.161 --- parse.y 2000/10/27 16:38:15 *************** *** 3288,3298 **** if (! arg_names.empty ()) { ! assert (arg_names.length () == tmp_nargin + 1); ! string_vector tmp_arg_names (tmp_nargin); ! for (int i = 0; i < tmp_nargin; i++) tmp_arg_names(i) = arg_names(i+1); tmp_args.stash_name_tags (tmp_arg_names); --- 3299,3314 ---- if (! arg_names.empty ()) { ! // tmp_nargin and arg_names.length () - 1 may differ if ! // we are passed all_va_args. ! ! int n = arg_names.length () - 1; ! ! int len = n > tmp_nargin ? tmp_nargin : n; ! string_vector tmp_arg_names (len); ! for (int i = 0; i < len; i++) tmp_arg_names(i) = arg_names(i+1); tmp_args.stash_name_tags (tmp_arg_names); ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------