error "iDummyBitOffset == -1"

Fabio79
2012-02-27
2012-03-03
  • Fabio79 - 2012-02-27

    Hi,
    I am using Codesys for ABB.
    The editor crashes and I find this error when, in simulation mode, I just try to open and visualize a module containing a vector with size 0. The error appears even when you login in simulation, without running the project.

    The reason why I have a vector with size 0 is simply because I want to generalize the modules of my own library: I set the size of the vector to 0 on the PLCs where I don't need to use that vector, instead of commenting code around the imported module.

    Here there is a simple code that reproduces the crash:

    VAR CONSTANT
    size : INT := 0; ( size >= 1: no problems )
    END_VAR

    VAR
    i : INT;
    v : ARRAY[1..size] OF INT;
    END_VAR

    ( PLC_PRG: )
    IF size>0 THEN ( this IF should be enough to avoid an erroneous access to v[1] e v[0] )
    FOR i:=1 TO size DO ( but codesys crashes anyway when you login )
    v[i] := 1;
    END_FOR
    END_IF

    Strange is that this error appears only when I debug the code: I manage to download this code on a PLC and the program run! Only the editor crashes..

    I would really appreciate every opinion on this matter!
    Thank's!

    IMG: error Codesys.png

    vector.pro [103.11 KiB]

     

    Related

    Talk.ru: 1

  • shooter - 2012-02-27

    LOL

    you define an array with -1 members
    if size = 0 then this is fault.
    v : ARRAY[1..size] OF INT;
    if you change the 1 to a zero always 1 member will be made.
    that is the minimum.
    you can not create an array with 0

     
  • spfeif - 2012-03-03

    Might I add one thing you are checking a constant "size" defined as 0 if it is greater than > 0 ? The constant will not change?

     

Log in to post a comment.