• Calling by reference - Cavo28SP4

    From Wolfgang Riedmann@21:1/5 to georg...@gmail.com on Mon Dec 21 16:36:02 2020
    Hi Georgi,

    I'm not sure about this, but I think real8 has a something different
    behavior.

    If the code on both sides is yours, why you don't use the float
    datatype?

    Wolfgang

    georg...@gmail.com wrote:

    Hello everyone,

    What is the best way to find the following problems with calling by
    reference in the software:

    function MyFunctioOne () as logic
    local nVar: = 0 as int

    MyFunctioTwo (@nVar)
    or
    MyFunctioTwo (nVar)

    return (true)

    function MyFunctioTwo (nVar ref real8) as logic
    ....
    nVar: = 1234.56

    return (true)

    Thanks in advance for the reply!

    Best regards.
    Georgi Georgiev



    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From georgiev.hr@gmail.com@21:1/5 to All on Tue Dec 22 04:04:33 2020
    Hello, Mr. Riedmann,

    Thanks for the reply.

    Maybe you didn't understand my question.

    I found bugs in the software and I want to check for others, but the features are many and manual checking would take a long time.
    I'm looking for incorrectly described with different types of variables to functions and those on which a reference call is incorrectly described.

    Regards,
    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jamal@21:1/5 to georg...@gmail.com on Tue Dec 22 16:24:03 2020
    When you don't pass the a variable by reference correctly, the compiler
    will give you a warning:

    Automatic Reference Generation: 51200.

    Just make sure Warnings is at least set to Low and Warnings as Errors is checked in the compiler options of the particular option.
    This will report all the issues at compile time and you will need to
    correct.

    Jamal

    On 12/18/2020 3:07 AM, georg...@gmail.com wrote:
    Hello everyone,

    What is the best way to find the following problems with calling by reference in the software:

    function MyFunctioOne () as logic
    local nVar: = 0 as int

    MyFunctioTwo (@nVar)
    or
    MyFunctioTwo (nVar)

    return (true)

    function MyFunctioTwo (nVar ref real8) as logic
    ....
    nVar: = 1234.56

    return (true)

    Thanks in advance for the reply!

    Best regards.
    Georgi Georgiev


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jamal@21:1/5 to Jamal on Tue Dec 22 23:38:22 2020
    Correction the "...the particular option" should say be "...the
    particular application"

    On 12/22/2020 4:24 PM, Jamal wrote:
    When you don't pass the a variable by reference correctly, the compiler
    will give you a warning:

    Automatic Reference Generation: 51200.

    Just make sure Warnings is at least set to Low and Warnings as Errors is checked in the compiler options of the particular option.
    This will report all the issues at compile time and you will need to
    correct.

    Jamal

    On 12/18/2020 3:07 AM, georg...@gmail.com wrote:
    Hello everyone,

    What is the best way to find the following problems with calling by
    reference in the software:

    function MyFunctioOne () as logic
        local nVar: = 0 as int
        MyFunctioTwo (@nVar)
    or
        MyFunctioTwo (nVar)

    return (true)

    function MyFunctioTwo (nVar ref real8) as logic
    ....
        nVar: = 1234.56

    return (true)

    Thanks in advance for the reply!

    Best regards.
    Georgi Georgiev



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From georgiev.hr@gmail.com@21:1/5 to All on Wed Dec 23 03:47:09 2020
    Thank you for the answer Jamal,

    Warnings are set on All and Warnings as Errors is checked on each application. However, I found an error with calling by reference.

    The compiler does not give an error if you have a variable of type int, for example, and call it by reference in a function in which it is described as real8.
    Any idea about that?

    Merry Christmas,

    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert van der Hulst@21:1/5 to All on Wed Dec 23 05:00:42 2020
    George,

    VO is very "forgiving" (sloppy) in this area. If a function expects a parameter by reference and you pass it a reference then it assumes that you know what you are doing and it does not complain.
    In your original example it will assume that the the nVar variable in the function points to a Real8 and will simply write the new value (8 bytes) at that location. Since you are passing an integer by reference this is more data then you expected, so
    this may corrupt the stack of the calling code.
    There is no way you can solve this in VO. And their will be no update to VO to fix this.
    The only way to solve this is by switching from VO to a new language, such as X#. X# will migrate that code from VO to .Net and the X# compiler WILL complain if you are mixing types.
    You do not have to run the code from X#, but you could use the migration to help diagnose your VO code and make the changes in VO.
    You can download X# at the site www.xsharp.info.

    Robert


    Thank you for the answer Jamal,

    Warnings are set on All and Warnings as Errors is checked on each application.
    However, I found an error with calling by reference.

    The compiler does not give an error if you have a variable of type int, for example, and call it by reference in a function in which it is described as real8.
    Any idea about that?

    Merry Christmas,

    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From georgiev.hr@gmail.com@21:1/5 to All on Wed Dec 23 06:05:56 2020
    Thank you for the answer Mr. Robert,

    As a result of the wrong type of variables, I got strange results in the software and that's why I started this topic.

    I installed X # a long time ago and continue to migrate the software.

    Thank you, I will take advantage of the good idea.

    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jamal@21:1/5 to georg...@gmail.com on Thu Dec 24 15:23:32 2020
    I see, just Robert said VO does not seem to check for the passed
    variable type. I never pass variables by reference; I think as you can
    see it's bug prone and you end with a corrupted return value.

    Jamal

    On 12/23/2020 6:47 AM, georg...@gmail.com wrote:
    Thank you for the answer Jamal,

    Warnings are set on All and Warnings as Errors is checked on each application.
    However, I found an error with calling by reference.

    The compiler does not give an error if you have a variable of type int, for example, and call it by reference in a function in which it is described as real8.
    Any idea about that?

    Merry Christmas,

    George


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From georgiev.hr@gmail.com@21:1/5 to All on Mon Jan 4 00:38:59 2021
    Happy New Year 2021 !

    Be healthy and have a lot of professional success!

    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)