Closed GoogleCodeExporter closed 8 years ago
I am not sure this is a bug. The first argument of printf is a pointer. If an
int is passed, what do you expect?
Original comment by christop...@gmail.com
on 28 Aug 2012 at 8:40
well, i expect the picoC says me exactly what you are telling me
instead of do segmentation fault and bad stuff
Original comment by carlojpi...@gmail.com
on 28 Aug 2012 at 11:39
You are right. Surprisingly, printf(0); segfaults while printf(1); returns the
error message "can't set char* from char in argument 1 of call to printf()".
In your example, since a is not explicitely initialised, it is set to 0.
Original comment by christop...@gmail.com
on 29 Aug 2012 at 2:26
Thanks for the analysis guys.
I've added a check for a null format pointer to printf() and friends.
Strangely enough, printf(0) is semantically valid (but will cause a crash)
because 0 is the same as a null pointer. printf(1) can be detected as having an
invalid data type because it requires passing the integer to a char * argument.
This is what you see now:
picoc> printf(0);
[null format]
Original comment by zik.sale...@gmail.com
on 30 Aug 2012 at 10:19
Original issue reported on code.google.com by
carlojpi...@gmail.com
on 27 May 2012 at 12:07