Jump to content
Sign in to follow this  
neilbuck

Use Of Ternary Operator Fails Compilation

Recommended Posts

Bug description:

Certain usage of the ternary operator fails to compile.

 

I would expect the following to compile which it does:

uiTest = (n>5) ? 4 : 7;

 

However I would also expect this to compile:

(uiTest > 5) ? n+=4 : n+=7;

 

however it complains with: error: missing semicolon.

 

I believe that this construct is ansi compliant but apologies if I'm mistaken

 

Steps to reproduce:

 

code: (uiTest > 5) ? n+=4 : n+=7;

 

 

Expected behaviour:

I would expect this to compile.

 

 

Is the problem 100% reproduceable:

100% reproduceable

 

IDE version: 5.7.1

Compiler: BoostC

Compiler version: 1.8 Alpha

Target device: PIC16F876a

OS: XP sp1

Comments:

None

Share this post


Link to post
Share on other sites

I will check this. Meanwhile you can use a workaround that is quite easy and will generate less code that the original expression you try to use:

 

n+=(uiTest > 5)?4:7;

 

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
I will check this. Meanwhile you can use a workaround that is quite easy and will generate less code that the original expression you try to use:

 

n+=(uiTest > 5)?4:7;

 

 

Regards,

Pavel

 

Thanks for the workaround which is a more elegant solution than the original code.

Share this post


Link to post
Share on other sites

This was a bug that now has been fixed. Fix will be available in the next release.

 

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