Jump to content

Uitoa_dec() Overwrites Following Variable Space

Recommended Posts

Bug description:

uitoa_dec() overwrites following variable space


Steps to reproduce:


#include <system.h>
#include <stdlib.h>

char buff[4];
unsigned int num = 1234;

void main( void )
uitoa_dec(buff, num, 4);



After calling uitoa_dec() num contains 1024 ($0400)



Expected behaviour:

The variable num should be untouched after uitoa_dec() has been called.


Is the problem 100% reproduceable:



IDE version: V6.95

Compiler: BoostC

Compiler version: V6.95

Target device: PIC16F628

OS: Win XP Pro SP3



This was first noted with V6.92 and upgrading to 6.95 has made no difference.





Link to post
Share on other sites

Not an error. Remember that strings include trailing zero. Your buffer is only 4 bytes long and trailing zero gets written past it where another variable is located.




Link to post
Share on other sites


Sorry, I realised the problem about 10 seconds after posting. I did know about the null but I seemed to have reverted to BASIC where an array of 10 would have 11 elements.


Anyway, thanks for the fast reply.



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.

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.

  • Create New...