Jump to content
Sign in to follow this  
rlang

Problem With Boostc 2.0.1

Recommended Posts

Bug description:

Structure variable testing produces incorrect results. Program compiled and executed with IDE 5.9 and BOOSTC 2.0.1

 

Steps to reproduce:

1 Compile the following program and execute in debug mode watching variables

midi->wait_bytes and midi->byte2.

 

// microprocessor is 18F2455
#include "system.h" //pic definition files required by boostc

typedef struct {
unsigned char cable;
unsigned char byte0;
unsigned char byte1;
unsigned char byte2;
unsigned char running_status;
unsigned char expected_bytes;
unsigned char wait_bytes;
unsigned char sysex_ctr;
}midi_rec;
midi_rec midi;
         
void main() 
{
// when this program is executed midi->byte2 is never set equal to 'A'
// even though midi->wait_bytes is equal to 0 the second time through.                   
                     unsigned char mybyte;
                     unsigned char i;
                     mybyte='A';
                     midi->wait_bytes=1;
                     for (i=0;i<2;i++)
                     {
                     if(midi->wait_bytes) // if wait bytes > 0 
         midi->byte1 = mybyte; // store in byte 1
         else  // if wait_bytes=0
          midi->byte2 = mybyte; // store in byte 2  
                midi->wait_bytes=midi->wait_bytes -1; 
                }   
}

 

Expected behavior:

The second execution of the for loop would place ‘A’ in midi->byte2.

 

Is the problem 100% reproducible:

Yes

BoostC Optimizing C Compiler Version 2.0.1 Beta (for PIC18 architecture)

success

BoostLink Optimizing Linker Version 2.0.1 Beta

 

Warning: Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz

Warning: argument of 'delay_10us' calls must have a value of 1 or more

Building CASM file

 

Memory Usage Report

===================

RAM available:2048 bytes, used:11 bytes (0.6%), free:2037 bytes (99.4%)

ROM available:24576 bytes, used:103 bytes (0.5%), free:24473 bytes (99.5%)

 

Successful

Done

OS: Windows 98

Comments: Is there a workaround?

Share this post


Link to post
Share on other sites

The problem seems to be not in the compiler but in the code. You use the '->' operation with a non-pointer:

 

midi->wait_bytes=1;

 

Try to correct the code to use '.' operation with the 'midi' variable.

 

The next BoostC release will issue warnings for these kind of errors and later these warnings will be replaced by error messages.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
The problem seems to be not in the compiler but in the code. You use the '->' operation with a non-pointer:

 

Regards,

Pavel

 

 

I'm sorry, I condensed too much of the program. The actual problem is shown below. Note that byte2 is never set.

 

// microprocessor is 18F2455
#include "system.h" //pic definition files required by boostc

typedef struct {
unsigned char cable;
unsigned char byte0;
unsigned char byte1;
unsigned char byte2;
unsigned char running_status;
unsigned char expected_bytes;
unsigned char wait_bytes;
unsigned char sysex_ctr;
}midi_rec;
midi_rec mymidi;

void itsasub(midi_rec *midi)
{
// when this program is executed midi->byte2 is never set equal to 'A'
// even though midi->wait_bytes is equal to 0 the second time through.                   
                     unsigned char mybyte;
                     unsigned char i;
                     mybyte='A';
                     midi->wait_bytes=1;
                     for (i=0;i<2;i++)
                     {
                     if(midi->wait_bytes) // if wait bytes > 0 
        midi->byte1 = mybyte; // store in byte 1
         else  // if wait_bytes=0
         midi->byte2 = mybyte; // store in byte 2  
               midi->wait_bytes=midi->wait_bytes -1; 
                }   
}          
void main()
{ 
itsasub(&mymidi);
}

Share this post


Link to post
Share on other sites
...I'm sorry, I condensed too much of the program.  The actual problem is shown below.  Note that byte2 is never set...

 

Of course this doesn't work and it is not even supposed to work as long as the '->' operator is used with a non pointer (as I described already). Try to replace it with the '.' operator and this should fix the problem. (Or don't I understand something ...?)

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Pavel (Rob),

 

For me this code compiles, with existing release of compiler, but does not work correctly.

 

With current development test compiler this code works correctly - so whatever

caused the problem is fixed.

 

Regards

Dave

Share this post


Link to post
Share on other sites
For me this code compiles, with existing release of compiler, but does not work correctly.

 

With current development test compiler this code works correctly - so whatever

caused the problem is fixed.

 

Hmmm this sounds interesting. The code may compile but it shouldn't work unless there are some coincidents that make it look like it works.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

Loading...
Sign in to follow this  

×
×
  • Create New...