bugGNU Octave - Bugs: bug #65140, incorrect value for nargin for...


bug #65140: incorrect value for nargin for command line script with bytecode interpreter

Submitter:  John W. Eaton <jwe>
Submitted:  Mon 08 Jan 2024 06:54:51 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Ready For Test Assigned to:  None
Originator Name:  jwe Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Wed 10 Jan 2024 10:03:36 PM UTC, comment #3: 

I edited the description a bit. "Make check" now does the full suite again. Pushed to https://hg.savannah.gnu.org/hgweb/octave/rev/925c2d47edb7

Arun Giridhar <arungiridhar>
Group Member
Wed 10 Jan 2024 08:08:12 PM UTC, comment #2: 

Oh ye the assumption in the code is that nargin is always zero for scripts.

Fix nargin for scripts in bytecode interpreter (bug #65140)

So that nargin calls in scripts properly matches argv or amount of function arguments, instead of always zero.

* stack-frame.cc: Set nargin
* test/compile/bytecode.tst: Do new test
* test/compile/bytecode_script_nargin.m: New test file
* test/compile/module.mk: Add new file

(file #55553)

Petter <petter>
Tue 09 Jan 2024 05:57:17 PM UTC, comment #1: 

CC'ing Petter.

This might also be the reason why it looks like the test-suite is always running with activated bytecode compiler in CI.

Markus Mützel <mmuetzel>
Group administrator
Mon 08 Jan 2024 06:54:51 PM UTC, original submission:  

Using Octave built from the bytecode-interpreter branch, I see the following in an interactive session started with some command line arguments:

$ /path/to/octave --no-init-file --no-line-editing --no-window-system
GNU Octave, version 10.0.0
Copyright (C) 1993-2024 The Octave Project Developers.
This is free software; see the source code for copying conditions.
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Home page:            https://octave.org
Support resources:    https://octave.org/support
Improve Octave:       https://octave.org/get-involved

For changes from previous versions, type 'news'.

octave:1> argv
ans =
  [1,1] = --no-init-file
  [2,1] = --no-line-editing
  [3,1] = --no-window-system

octave:2> nargin
ans = 3

That is expected behavior.  However, if I create a script file containing the lines


I see the following output when passing the name of the script on the Octave command line with extra arguments after the name of the file:

$ /path/to/octave foo.m one two three
ans =
  [1,1] = one
  [2,1] = two
  [3,1] = three

ans = 0

The value of argv is correct but nargin should be 3 here, not 0.

This affects the way "make check" works if Octave is built in a directory outside the source tree.  In that case, all the tests in files from the source tree are skipped.

John W. Eaton <jwe>
Group administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #55553:  octave_33150.patch added by petter (4KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by petter (Updated the item)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by jwe (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-10 arungiridhar StatusNone Ready For Test
    2024-01-10 petter Attached File- Added octave_33150.patch, #55553
    2024-01-09 mmuetzel Carbon-Copy- Added petter

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code