|
|
View previous topic :: View next topic |
Author |
Message |
C-H Wu Guest
|
Amazing bug, PCH 3.203 ~ 3.211, (pi/2)*(2/pi) equals 0.5 !! |
Posted: Fri Sep 24, 2004 8:45 am |
|
|
I just can't believe my eye, when I modified the cos() in math.h, everything fine except I got a 0.707 for sin(0.0) ! Then I dig into my code, then I dig deeper, then ... bingo!
Here is the bug for weekend.
Code: | // bug_3211_MULFF.c by C-H Wu 2004/09/24
//
// (pi/2)*(2/pi) equals 0.5 !!
//
// bug exist since PCH 3.203, when they 'improved' the @MULFF
//
#include <18F458.H>
#use delay(clock=20000000 )
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)
//#define PI 3.141592 // no bug
#define PI 3.1415927 // BUG !! (pi/2)*(2/pi) equals 0.5 !!
#define PI_DIV_BY_TWO (PI/2.0)
#define TWO_DIV_BY_PI (2.0/PI)
void main()
{
float x, y;
x = PI_DIV_BY_TWO;
y = x * TWO_DIV_BY_PI;
printf("\r\n\n PI_DIV_BY_TWO * TWO_DIV_BY_PI = %f", y );
while (1);
}
|
I reported to CCS, try it for yourself.
Best wishes |
|
|
C-H Wu Guest
|
Bug fixed in 3.212 |
Posted: Sat Sep 25, 2004 12:54 am |
|
|
fixed in 8 hours ! |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Sep 25, 2004 5:54 am |
|
|
Great for CCS to be this fast with a bugfix and new release! 3.212 already!
But I do hate the release notes!
Quote: | 3.212 A %u and %d bug is fixed |
This doesn't say anything about what went wrong, so how can you guess the impact of this bug on your projects? In fact, I think the release note is misleading because it doesn't mention a bug in the multiply going wrong! Look in the example code given by C-H Wu, no %u or %d to be seen there.
I also would like to see CCS mentioning this bug was present since v3.203, this again would help me in deciding when to upgrade to a new version.
I noticed before the CCS release notes not being complete, of the three confirmed bugs I reported only one showed up in the release notes. |
|
|
C-H Wu Guest
|
demo code for the %u bug in PCH 3.211 |
Posted: Sat Sep 25, 2004 6:30 am |
|
|
ckielstra wrote: | Great for CCS to be this fast with a bugfix and new release! 3.212 already!
But I do hate the release notes!
Quote: | 3.212 A %u and %d bug is fixed |
|
Here is the story and demo code for the bug in %u I e-mailed to CCS.
Bug report for PCH 3.211,
printf( "\r\n\n %u", 103 ); print out ... '13' !! same for sprintf().
PCH 3.210 does not has this bug
Code: |
// bug_3211_printf.c by C-H Wu 2004/09/24
//
#include <18F458.H>
#use delay(clock=20000000 )
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)
int8 i, x= 90, str[6]={};
void main()
{
printf("\r\n\n Bug PCH 3.211 !");
printf( "\r\n\n %u", 113 ); // ok
printf( "\r\n\n %u", 103 ); // BUG !! print out ... '13' !!
sprintf( str, "%u", 103 ); // BUG !!
for (i=0; i<5; i++) printf("\r\n i= %u, str[%u]= 0x%2x", i,i,str[i]);
printf("\r\n press any key to see more bugs ..."); getc();
while (1)
{
printf( "\r\n x= %u", x ); // BUG !! for x = 100 ~ 109 or 200 ~ 209
sprintf( str, "%u", x++ );// BUG !! same as above
for (i=0; i<5; i++) printf("\r\n i= %u, str[%u]= 0x%2x", i,i,str[i]);
delay_ms(500);
}
} |
I knew 3.210 works fine with my big program while 3.211 does not. But I did not investigate the 3.211 bug until I found the MULFF bug in 3.203~3.211, well, that is the point I have to find out the 3.211 bug, otherwise the 3.211 bug will still exist in 3.212 even with the MULFF bug get fixed. It turns out to be the %u bug ! So, I e-mailed two bug reports in 3 hours. The good news is that both bug was fixed in 3.212 in 8 hours! I think the reason why they didn't mention the MULFF bug is because the possibility to get this bug is almost zero, while the %u bug is a serious bug.
The only thing left to be done by CCS is to replace the demo version, which happened to be 3.211d and turns out to be a printf(), sprintf() bug demo !
I believe that the 3.211d will soon be replaced with 3.212d.
Cheers ! |
|
|
Guest
|
|
Posted: Sat Sep 25, 2004 1:15 pm |
|
|
Compiler version 3.206
Code: |
float average, WordValue;
int8 AccDays;
WordValue = 465.00;
AccDays = 2;
average = WordValue / (float)AccDays;
printf("AVG: %3.2f", average);
|
AVG : 232.00 (???)
Code: |
WordValue = 464.00;
AccDays = 2;
average = WordValue / (float)AccDays;
printf("AVG: %3.2f", average);
|
AVG : 231.99 (???) |
|
|
Guest
|
|
Posted: Sat Sep 25, 2004 7:27 pm |
|
|
Anonymous wrote: | Compiler version 3.206
Code: |
float average, WordValue;
int8 AccDays;
WordValue = 465.00;
AccDays = 2;
average = WordValue / (float)AccDays;
printf("AVG: %3.2f", average);
|
AVG : 232.00 (???)
Code: |
WordValue = 464.00;
AccDays = 2;
average = WordValue / (float)AccDays;
printf("AVG: %3.2f", average);
|
AVG : 231.99 (???) |
tested with 3.206 and 3.212 for 16F877 and 18F458, no problem at all.
Code: | Hello world ! AVG: 232.49
Hello world ! AVG: 231.99
|
%11.6f will print out 231.999999 |
|
|
Guest
|
|
Posted: Sat Sep 25, 2004 8:49 pm |
|
|
You know that in the same version there are more than one change/fix, so you are right but I´m right too !!!
Compiler version 3.206 and 16F877
Code: |
float average, WordValue;
int8 AccDays;
WordValue = 465.00;
AccDays = 2;
average = WordValue / (float)AccDays;
printf("AVG: %3.2f", average);
|
AVG : 232.00
regards. |
|
|
Trampas
Joined: 04 Sep 2004 Posts: 89 Location: NC
|
|
Posted: Sun Sep 26, 2004 9:31 am |
|
|
I agree that CCS needs a bug tracking system. I know personally I have been bitten more than once by a bug in one compiler version, which was fixed in another, then broken again in the next release.
Personally I am starting to migrate my development efforts to a more stable compiler. I like the CCS compiler but it is getting to be more effort to determine if bugs or are mine or compilers. That is I can go with a more stable compiler, then take time to manually optimize code and save more time that using the CCS compiler.
Don't get me wrong CCS is great compiler! However most of my programs are around 10k lines and are well over 60k bytes of code. Thus the compiler problems are hurting more and more each day and with every compiler update.
I break out in sweat each time their is a compiler update because I do not know if it will fix more problems than it breaks. So basically I am losing faith in the compiler and CCS. I am not trying to speak ill of CCS I am just trying help by point out what I as customer feel and think. Basically if CCS does not know there is problem then they can not fix it, so I feel that in order to help CCS we need to state our problems and pains. Then CCS needs to acknoledge these concerns, which I feel they have not. With out the acknoledgment, we are left wondering if they heard what we said and/or if they heard and just do not care. For example, I stopped sending bug reports to CCS, as that I never get anything back from them that the bug was fixed or even looked at. Instead I post the bugs here for other to see as I get some feedback that the problem is with compiler or my code.
Trampas |
|
|
C-H Wu Guest
|
Is 3.212 stable ? |
Posted: Sun Sep 26, 2004 10:29 pm |
|
|
I totally agree with Trampas's feeling. That is why I have to spend so many hours to make bug demo code such that they can fix it quickly, and they did response very fast with these simple bug demo.
My personal feeling is 3.212 is quite stable now, so, don't upgrade unless necessary should let us stay happy.
Cheers. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|