Jump to content

Bug in simple math with a for loop

Dean Mills

Recommended Posts

Hi all,

A collegue of my found this bug.

There is a bug in LabVIEW 7.1 where if you have a for loop, a constant outside the loop and do simple math, such as subtract on a constant that resides inside the for loop it treats the top terminal as 0 . See attached.


Place a for loop on the diagram, wire 1 to the count terminal

Place a constant on the diagram outside the for loop, use any postive number.

Place a constant inside the for loop, use any positive number.

Subtract them with the constant outside the for loop wired to the top terminal.

Wire the result of the subtract to the output of the for loop, disable indexing.

Wire the top terminal to the output of the for loop, disable indexing.

Probe the output of the subtract.

Run VI

I have tried add, multiple and divide. Same bad results

This has been submitted to NI as a bug report.

DeanDownload File:post-5-1097694319.vi

Link to comment

This has been submitted to NI as a bug report.

DeanDownload File:post-5-1097694319.vi


VERY strange ! :wacko: The inside indicator, a probe and execution highlighting all show the constant 60 as being passed correctly.

If the inside and outside constants are reversed, the problem does not occur.

If the outside constant is changed to an array, enabling auto indexing, the problem goes away.

No similar bug exists in the while loop.

I'm amazed that this bug has only surfaced now.


Download File:post-658-1097697369.vi

Link to comment

Hello LabVIEW Users,

Thank you for reporting this issue. Prior to 10/13/2004, National Instruments was not aware of this issue, and we apologize for any inconvenience it has caused.

We have since investigated this issue, and I would like to pass along more details about it. This issue occurs when a wire is connected to a For Loop, through the For Loop's diagram, and out the other side of the For Loop, with indexing disabled. Within the For Loop, the wire is branched to one of several operations such as Add, Subtract or Increment. When the original wire comes from a constant or a computed constant and all other wired inputs to the function are also constants or computed constants, the output of the function inside the For Loop can produce a wrong result. The wrong result will either be the constant value itself, or the result which would be produced by the default value for that type, depending upon the operation.

While we feel that this issue should affect relatively few real-world applications, we are presently working on a longer-term solution for this, and will post more information in the NI Discussion Forum thread when it is available.

Jeff Boettcher

Product Support Engineer

National Instruments - LabVIEW R&D

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.