Jump to content

Bug In Subtracting Two Elements Of A Struct.


Recommended Posts

Hi,

 

I found a bug in BoostC 6.25.

 

#include <system.h>


unsigned char subtract(void);


struct{
       unsigned short a;
       unsigned long b;
      } test;

unsigned char result;


void main()
{
 test.a = 545;
 test.b = 1000944;
 result = subtract();
 while(1);
}


unsigned char subtract(void)
{
 unsigned long var;
 
 var = test.b - test.a;
 
 if(var==1000399) return(1);
 else return(0);
}

After var = test.b - test.a var is 0 instead of 1000399!

 

Regards, Teuniz

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...
×
×
  • Create New...