Print a Negative Integer bug in compact printf
Christof Eb.
Posts: 1,237
Hi,
there seems to be a bug in compact printf.
#include <stdio.h>
#include <propeller.h>
#include <sys/thread.h>
#include <math.h>
int main (void)
{
int a=123, b=-456;
sleep(2);
printf("hello, world! %d %d\n", a, b);
return 0;
}
brings:
hello, world! 123 -456 without compact printf
hello, world! 123 4294966840 with compact printf
Best regards
Christof
there seems to be a bug in compact printf.
#include <stdio.h>
#include <propeller.h>
#include <sys/thread.h>
#include <math.h>
int main (void)
{
int a=123, b=-456;
sleep(2);
printf("hello, world! %d %d\n", a, b);
return 0;
}
brings:
hello, world! 123 -456 without compact printf
hello, world! 123 4294966840 with compact printf
Best regards
Christof
Comments
BTW, libtiny.a compiled for LMM will not work with CMM. We've packaged the library versions that are automatically included by GCC based on the model used.
I use SimpleIde (Great tool!) and just set the hook for compact printf or omit it.
Christof
I'm not able to reproduce the problem by either checking "Simple Printf" or "Tiny Lib" with version 0-8-5.
Can you please after building the failing condition, right-click build status and select-all, then copy and paste here?
Thanks,
--Steve
BTW, I'll be on line only briefly the rest of today/tonight.
Project Directory: C:/Users/Christof/Documents/SimpleIDE/SineBurst/
propeller-elf-gcc.exe -o a.out -Os -mcmm -I . -Wall -m32bit-doubles -fno-exceptions -Dprintf=__simple_printf -save-temps Test_prt.c -lm
Test_prt.c: In function 'main':
Test_prt.c:18:5: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
propeller-elf-objdump -h a.out
Done. Build Succeeded!
propeller-load.exe -I C:/propgcc/propeller-load/ -b DEMOBOARD -p COM6 a.out -r
Propeller Version 1 on COM6
Loading a.out to hub memory
10180 bytes sent
Verifying RAM ...
OK
========================================================================================
Oh, I have just seen, that if I don't select maths library, it is working and I get very much smaller code. That's funny.
Thanks Christof, that was just the clue we need. The version of _simple_printf in the math library has floating point support and support for 64 bit integers, which is why it's bigger, and also why it isn't working -- the integer parsing code is using 64 bit integers and not checking for 32 bit negative numbers. It should be easy to fix.
Thank you for the bug report!
Eric