[Bug 773] New: Nan or segfaults in scripting when assigning int to array

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=773

Summary: Nan or segfaults in scripting when assigning int to
array
Product: RTT
Version: 1.10.1
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P3
Component: Real-Time Toolkit (RTT)
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

I had trouble using array in a state machine or a program.
This code :

var array myArray(10);
 
for (var int cpt = 0; cpt < 10; set cpt = cpt +1 )
{
    set myArray[cpt] = cpt;
}

can produce nan values, or even a segfault.

This code :

var array myArray(10);
 
for (var int cpt = 0; cpt < 10; set cpt = cpt +1 )
{
    set myArray[cpt] = 1.0*cpt;
}

seems to run well.

[Bug 773] Nan or segfaults in scripting when assigning int to ar

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=773

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution| |FIXED
Status|ASSIGNED |RESOLVED

--- Comment #2 from Peter Soetens <peter [..] ...> 2010-06-18 14:14:02 ---
Fixed on trunk and back-ported to 1.10 branch.

[Bug 773] Nan or segfaults in scripting when assigning int to ar

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=773

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |next-bugfix
Status|NEW |ASSIGNED

--- Comment #1 from Peter Soetens <peter [..] ...> 2010-06-18 13:39:46 ---
Segfault confirmed with this test case:

BOOST_AUTO_TEST_CASE(testProgramAssignArrayIndex)
{
    // see if assigning an array from an int works (bug #773)
    string prog = string("program x {\n")
        + "var array myArray(10);\n"
        + "for (var int cpt = 0; cpt < 10; set cpt = cpt +1 )\n"
        + "{\n"
        + "   set myArray[cpt] = cpt;\n"
        + "}\n"
        + "for (set cpt = 0; cpt < 10; set cpt = cpt +1 )\n"
        + "{\n"
        + "   do test.assert( myArray[cpt] == cpt );\n"
        + "}\n"
        + "}\n";
    this->doProgram( prog, &gtc );
    this->finishProgram( &gtc, "x");
}