View unanswered posts | View active topics It is currently Sat Oct 25, 2014 3:23 pm






Reply to topic  [ 3 posts ] 
Array of struct bug 
Author Message
Rookie

Joined: Sun Oct 28, 2007 10:28 am
Posts: 4
Post Array of struct bug
There is an bug when you pass an array of struct as a parameter. The data becomes garbled with a call by a parameter, but not when you set the values inline. The following code illustrates the problem. The correct output is: 0, 10, 100 -> 1, 11, 101 -> 2, 12, 102 which it displays using the inline method. When I fill the array of structs with a call the output is garbled.

BTW, is there a better place to report bugs?

Gordon

Code:
typedef struct {
   int low;
   int med;
   int high;
} datum;

typedef datum data[3];

void load_data (data &input)
{
   int i;

   for (i = 0; i < 3; i++) {
      input[i].low = i;
      input[i].med = i + 10;
      input[i].high = i + 100;
   }
}

task main()
{
   int i;
   data my_data;

   // Load array of structs without call
   for (i = 0; i < 3; i++) {
      my_data[i].low = i;
      my_data[i].med = i + 10;
      my_data[i].high = i + 100;
   }
   eraseDisplay();
   for (i = 0; i < 3; i++) {
      nxtDisplayTextLine(0, "%d", my_data[i].low);
      nxtDisplayTextLine(1, "%d", my_data[i].med);
      nxtDisplayTextLine(2, "%d", my_data[i].high);
      wait10Msec(200);
   }

   // Set all data to known value
   for (i = 0; i < 3; i++) {
      my_data[i].low = 999;
      my_data[i].med = 999;
      my_data[i].high = 999;
   }

   // Load array of structs with call
   load_data(my_data);
   eraseDisplay();
   for (i = 0; i < 3; i++) {
      nxtDisplayTextLine(0, "%d", my_data[i].low);
      nxtDisplayTextLine(1, "%d", my_data[i].med);
      nxtDisplayTextLine(2, "%d", my_data[i].high);
      wait10Msec(200);
   }
}


Thu Nov 08, 2007 10:11 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post 
Yes, there is a bug tracker. Please report this bug here:

http://www-education.rec.ri.cmu.edu/man ... n_page.php

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Thu Nov 08, 2007 10:45 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
There was a bug in the code generator when struct arrays are passed by reference as a function parm. This is now fixed and will be available in the release 1.12 and later.


Wed Nov 14, 2007 1:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.