-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
newlib-nano: Printf formatting does not work properly for some numeric types #1891
Comments
For msba2 and iot-lab_M3 I used the same toolchain (ARM Embedded with gcc 4.8.4 20140725), btw. |
Please try |
respectively |
This is a result of newlib-nano. When omitting
in |
I only get the right result when setting |
With 2014-10-28 15:16:00,505 - INFO # abcdef0123456789
2014-10-28 15:16:00,505 - INFO # a
2014-10-28 15:16:00,505 - INFO # abcdef0123456789 The second printf throws a warning main.c:31:5: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' [-Wformat=]
printf("%lx\n", test);
^ |
Get the same result with the same configuration as @thomaseichinger has. The second printf was just a fall-back case, since |
Hm, there's certainly an issue with some formatters and printf in combination with a certain toolchain, platform, and optimization flags. |
@OlegHahm could you tell us your toolchain version and platform? I'd add a section to iot-lab_M3's wiki page. |
As this issue is related to newlib-nano close this as Memo? @OlegHahm @authmillenon |
|
This problem is probably caused by the stack alignment. Cortex-M stacks MUST be 8 byte aligned I see in the implementation of |
This should be fixed since #2976 in https://github.com/RIOT-OS/RIOT/blob/master/cpu/cortexm_common/thread_arch.c |
Yeah I just saw it in the thread_arch, I've seen this before when the stack was misaligned, my bad. |
No problem. |
But the described bug in this issue is still present? |
Long time I haven't checked. |
Possible job for @A-Paul ? Or are you already busy with work? |
Bug is still present. Checked today, to see if the stack alignment was correct and it was. |
Wondering if there is anything we can do about this. Seems more like Newlib-nano issue. |
This could definitely go into a documentation, its common that I write something like |
Can't we instead enforce the usage of
Is this really per platform or per architecture? It's hard for me to think that such a |
That doesn't help. The problem is that depending on compile time configuration of newlib, it might or might not support "%z".
It totally depends on how the C library was compiled. |
So what do we do here? It seems that is also a won't fix... |
I added some reference in the coding conventions: https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions#-wformat Feel free to add more informations and rephrase. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This should not have been closed, its still an issue, the thing happens with |
I see the following approaches to move forward:
|
I'm wondering if we could even implement a compile-time warning when using newlib_nano and printf. |
Possibly other boards are effected, too. Compare the following program
on iot-lab_M3
on native
and on msba2
The text was updated successfully, but these errors were encountered: