View unanswered posts | View active topics It is currently Wed Jul 30, 2014 10:04 am






Reply to topic  [ 12 posts ] 
RobotC FATAL error: Compiler error allocating new temporary 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post RobotC FATAL error: Compiler error allocating new temporary
Does anybody know what this error means for the following code? This code is part of a library. It compiles perfectly fine in other more complex programs but gives me the error below in a test program.

**FATAL**:Compiler error allocating new temporary (HWM mismatch 12 (temp) vs 8 (pass 1 max)). Pass/Seq: 'Emit Code:112

Code:
bool SMIsReady(SM &sm)
{
    bool fReady;

    if (((sm.smFlags & SMF_READY) == 0) &&
        (sm.timeout > 0) &&
        ((long)nPgmTime >= sm.timeout))
    {
        sm.smFlags |= (SMF_TIMEOUT | SMF_READY);
        if (sm.fClearEvts)
        {
            sm.fClearEvts = false;
            SMClearAllEvents(sm);
        }
        sm.currState = sm.nextState;
    }
    fReady = (sm.smFlags & SMF_READY) != 0; <<<< Here is where the error occurred

    return fReady;
}   //SMIsReady


Fri Dec 03, 2010 3:57 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
It's probably be a bug in the compiler. Send the smallest test program you can make that reproduces the bug with the above code to support@robotc.net.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Dec 03, 2010 5:42 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC FATAL error: Compiler error allocating new temporary
Striping down the program to the simplest and yet reproducing the bug is the time consuming part :breakcomputer: :wink:

Our FTC regional is this weekend, so I probably won't have time until afterwards.


Fri Dec 03, 2010 5:44 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
MHTS,

Do you have a work-around for now? Mail the program + library to me (mightor_a@t_gmail_.dot._com). I'll strip it down and mail the devs.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Dec 03, 2010 5:58 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC FATAL error: Compiler error allocating new temporary
Thanks Xander!

I don't have a workaround. Like I said, this compiles fine for the competition program. It is only a problem with a test program. So I am not blocked by it.

I just checked in the code to our source control server. You can access it on:
http://proj.titanrobotics.net/hg/Ftc/20 ... b2179bd075

The test program that caused the error is in test\LnFollower.c.

Good luck in stripping it down. :)


Fri Dec 03, 2010 6:11 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
I found out what the problem was.

in sm.h , the SM struct is declared as follows:
Code:
typedef struct
{
    int  currState;
    int  nextState;
    long timeout;
    int  smFlags;
    bool fClearEvts;
    int  nWaitEvents;
    WAIT_EVT WaitEvents[MAX_WAIT_EVENTS];
} SM;


The offending piece of code tries this:
Code:
fReady = (sm.smFlags & SMF_READY) != 0;


An easy work-around and proper fix of your code is to resize smFlags:

Code:
typedef struct
{
    int  currState;
    int  nextState;
    long timeout;
    long smFlags;
    bool fClearEvts;
    int  nWaitEvents;
    WAIT_EVT WaitEvents[MAX_WAIT_EVENTS];
} SM;


Now it compiles just fine. I guess size really does matter :)

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Dec 03, 2010 6:59 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC FATAL error: Compiler error allocating new temporary
But why? As I understand it, int in RobotC is 16 bits and I am using only 16 bits and doing bit-wise operation on 16 bit. Why is it a problem? I think the real problem is not the size, the real problem is SMF_READY happens to be the sign bit of the 16-bit int. If I changed SMF_READY to be 0x0200 instead of 0x8000, it works too. But still, why is this a problem?

Interestingly, the same library module used in another program compiles fine.

BTW, why is RobotC not supporting unsigned for all basic types? This is not very intuitive at all. I would have declared it as "unsigned int smFlags" if RobotC supports it.


Sat Dec 04, 2010 2:54 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
The only signed/unsigned type ROBOTC knows is the byte. I still think this is a bug but you have a good work-around now that will tide you over until the compiler is fixed.

The following code will produce a warning:
Code:
task main () {
  unsigned int foo = 0;
  unsigned long baz = 0;
 
  while(true) EndTimeSlice();
}


*Warning*:ROBOTC only supports 'unsigned' qualifier on 'byte' / 'char' sized variables. Ignored for other type.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Dec 04, 2010 3:11 am
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC FATAL error: Compiler error allocating new temporary
Yes, I know RobotC supports unsigned only for byte type (I tried it long time ago). That's why I don't understand the reason it doesn't support unsigned for other types. In my honest opinion, it is not orthogonal. It could introduce subtle bugs for both user code and the compiler. The unsigned qualifier should be applicable to all basic types.


Sat Dec 04, 2010 3:19 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
You could write a request for change to support@robotc.net but I wouldn't hold out too much hope for it to be implemented. All environments have their limitations and this lack of unsigned ints and longs is just something you'll have to work with :)

I do think what you've seen is a bug or at least something that should be handled differently by the compiler. I will send the devs the code that causes this problem so they can take a look at it and perhaps fix it.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Dec 04, 2010 3:40 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: RobotC FATAL error: Compiler error allocating new temporary
I've mailed the devs.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Dec 04, 2010 3:50 am
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC FATAL error: Compiler error allocating new temporary
Thanks Xander!


Sat Dec 04, 2010 3:54 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 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.