View unanswered posts | View active topics It is currently Wed May 22, 2013 4:22 pm






Reply to topic  [ 3 posts ] 
RobotC 3.51 bug 11 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1023
Post RobotC 3.51 bug 11
I just downloaded Xander's latest driver and when compiling with it, it gave me a warning on hitechnic_irseeker-v2.h:
*Warning*:Comparison between 'signed' and 'unsigned' operands.
I think RobotC doesn't like the comparison of (HTIRS2_I2CReply[iMax - 1] > (HTIRS2_I2CReply[iMax]/2). When you divide HTIRS2_I2CReply[iMax]/2, the compiler converted the unsigned value to signed. So you are comparing a unsigned value with a signed value and hence the warning.
Code:
  // Check signal strength of neighbouring sensor elements
  if ((iMax > 0) && (HTIRS2_I2CReply[iMax - 1] > (HTIRS2_I2CReply[iMax] / 2)))
  {
      dir--;
      dcSigSum += HTIRS2_I2CReply[iMax - 1];
  }

  if ((iMax < 4) && (HTIRS2_I2CReply[iMax + 1] > HTIRS2_I2CReply[iMax] / 2))
  {
      dir++;
      dcSigSum += HTIRS2_I2CReply[iMax + 1];
  }

However, even if I type cast it back to ubyte, the warning does not go away. I think that's a RobotC bug.
I simplified the code to the following to demonstrate the issue.
Code:
task main()
{
    ubyte x = 10;
    ubyte y = 20;

    if ((ubyte)(x/2) > y)
    {
        nxtDisplayTextLine(0, "x/2 > y");
    }
    else
    {
        nxtDisplayTextLine(0, "x/2 <= y");
    }
}


Sun Sep 30, 2012 3:02 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: RobotC 3.51 bug 11
Yeah, I saw that warning, but I couldn't remember if I'd submitted a report to Dick and Tim about it already. It's a non-fatal issue, but it's going to generate questions from users, if left unsolved.

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Sep 30, 2012 8:55 am
Profile WWW
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 613
Post Re: RobotC 3.51 bug 11
I confirmed that there are no error messages in the current development version which will be released soon.


Mon Oct 15, 2012 3:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 0 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.