octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53027] Strange behavior of globals with load


From: Lars Kindermann
Subject: [Octave-bug-tracker] [bug #53027] Strange behavior of globals with load
Date: Wed, 31 Jan 2018 03:19:03 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0

URL:
  <http://savannah.gnu.org/bugs/?53027>

                 Summary: Strange behavior of globals with load
                 Project: GNU Octave
            Submitted by: larskindermann
            Submitted on: Wed 31 Jan 2018 08:19:02 AM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

load() of a global inside a function leads to several strange effects: 
- The value outside the function does not change   
- It cannot be cleared anymore

Test code (bugGlobal.m): 

global X

function saveX
 global X
 disp "inside saveX"
 X=1
 save -binary fileX X
endfunction

function loadX
 global X
 disp "inside loadX:"
 X=2
 load fileX
 disp "inside loadX after load:"
 X
endfunction

disp "starting:"
X=0
saveX
disp "after saveX:"
X
loadX
disp "after loadX:"
X
load fileX
disp "after load:"
X
clear all
disp "after clear:"
X


This is the correct output of version 4.0 

starting:
X = 0
inside saveX
X =  1
after saveX:
X =  1
inside loadX:
X =  2
inside loadX after load:
X =  1
after loadX:
X =  1
after load:
X =  1
after clear:
error: 'X' undefined near line 32 column 2
error: called from
    bugGlobal at line 32 column 2


This is the strange output of current dev 

starting:
X = 0
inside saveX
X =  1
after saveX:
X =  1
inside loadX:
X =  2
inside loadX after load:
X =  1
after loadX:
X =  2
after load:
X =  1
after clear:
X =  1


This is the even stranger output of a second execution of the code

starting:
X = 0
inside saveX
X =  1
after saveX:
X = 0
inside loadX:
X =  2
inside loadX after load:
X =  1
after loadX:
X = 0
after load:
X =  1
after clear:
X =  1






    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 31 Jan 2018 08:19:02 AM UTC  Name: bugGlobal.m  Size: 349B   By:
larskindermann

<http://savannah.gnu.org/bugs/download.php?file_id=43137>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53027>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]