https://bugs.documentfoundation.org/show_bug.cgi?id=145279

            Bug ID: 145279
           Summary: ByRef argument modified in called Sub is returned
                    incorrectly
           Product: LibreOffice
           Version: 7.2.2.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Description:
The same Basic function executed
1. once with a default argument
2. once with an explicit argument
(both arguments having the same value),
does not show the same behaviour.

See code below that adds 1 to the value 10. The results are
1. 10 (obviously not what is expected)
2. 11

REM ***********************************************
Sub Main()
        MsgBox Plus1()                  '       Displays 10             => NOK
        MsgBox Plus1(10)                '       Displays 11             => OK
End Sub

REM ***********************************************
Function Plus1(Optional a)
        If IsMissing(a) Then a = 10
        Add1(a)
        Plus1 = a
End Function

REM **********************************************
Sub Add1(ByRef a)                       '       Note the "ByRef"
        a = a + 1
End Sub 

Steps to Reproduce:
1. Copy the example code in a Basic module of a new empty document
2. Run the Main() Sub

Actual Results:
1. The value "10" is returned
2. The value "11" is returned

Expected Results:
The value "11" should be returned twice


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.2.2.2 / LibreOffice Community
Build ID: 02b2acce88a210515b4a5bb2e46cbfb63fe97d56
CPU threads: 6; OS: Linux 5.4; UI render: default; VCL: kf5 (cairo+xcb)
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to