Jump to content
Sign in to follow this  
manuel123

Bug In V6.93: Triple Add

Recommended Posts

Bug description:

A triple add on unsigned short global variables and function return values fails when compling with -O2 or -Oa

 

Steps to reproduce:

In the following code the variable 'a' should be calculated to 4 but it is calculated to 5 instead. If the code is compiled with -O0 or -O1 the result is correct.

 

unsigned short a = 1;

unsigned short bar()
{
return 1;
}

void main()
{
// when compiling with -O2 or -Oa
// the following line results in 5 instead of 4
a = a + a + a + bar();
}

 

Expected behaviour:

The variable 'a' should be calculated to 4.

 

Is the problem 100% reproduceable:

Yes, every time with the code above and -O2 or -Oa.

 

IDE version: 6.93

Compiler: BoostC

Compiler version: 6.93

Target device: PIC16F88

OS: WinXP Home SP3

 

Comments:

Project file and source code are attached in the zip.

AddAdd.zip

Share this post


Link to post
Share on other sites

manuel123,

Bug description:

A triple add on unsigned short global variables and function return values fails when compling with -O2 or -Oa

 

Steps to reproduce:

In the following code the variable 'a' should be calculated to 4 but it is calculated to 5 instead. If the code is compiled with -O0 or -O1 the result is correct.

 

unsigned short a = 1;

unsigned short bar()
{
return 1;
}

void main()
{
// when compiling with -O2 or -Oa
// the following line results in 5 instead of 4
a = a + a + a + bar();
}

 

Expected behaviour:

The variable 'a' should be calculated to 4.

 

Is the problem 100% reproduceable:

Yes, every time with the code above and -O2 or -Oa.

 

IDE version: 6.93

Compiler: BoostC

Compiler version: 6.93

Target device: PIC16F88

OS: WinXP Home SP3

 

Comments:

Project file and source code are attached in the zip.

This is indeed a problem and now on our bugs list. It has been there for a long long time. I'm quite surprised no one has spotted it before. Thanks for the report.

 

Regards

Dave

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