scanf fails on "%hhx"

Bug #1598122 reported by john
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Invalid
Undecided
Unassigned

Bug Description

unsigned char i;
sscanf("9f", "%hhx", &i);
This code yields i = 9, which is wrong.

unsigned short i;
sscanf("9f", "%hx", &i);
This code yields i = 0x9f, which is correct.

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Hi John,

I agree with the fact the behavior you are observing is wrong. However, I am not able to reproduce it with the latest release. What version are you using?

Cheers,
Andre

Revision history for this message
john (jkovach) wrote :

Hi Andre,

It's 4.8 2014q3.
LDFLAGS=-Wl,-Map=$(MAP),--gc-sections -fwhole-program -static --specs=nano.specs -lc -lm -lnosys

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Ah that explains it. You are linking it against newlib-nano, which does not support C99 IO formats. I.e. Newlib-nano does not support 8bit types IO formatting.

Changed in gcc-arm-embedded:
status: New → Invalid
Revision history for this message
john (jkovach) wrote :

Thank you for the explanation, Andre.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.