Bug 23278 - printf using %a inconsistent
Summary: printf using %a inconsistent
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: stdio (show other bugs)
Version: 2.27
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-12 16:57 UTC by Fred Tydeman
Modified: 2019-07-09 13:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Tydeman 2018-06-12 16:57:42 UTC
This code

#include <stdio.h>

int main(void){
  (void)printf("%.0a\n", 1.);
  (void)printf("%.0a\n", 2.);
  (void)printf("%.0a\n", 4.);
  (void)printf("%.0a\n", 8.);
  (void)printf("%.0a\n", 16.);
  (void)printf("%.0a\n", 3.);
  (void)printf("%.0a\n", 6.);
  (void)printf("%.0a\n", 12.);
  (void)printf("%.0a\n", 23.);
  (void)printf("%.0a\n", 24.);
  (void)printf("%.0a\n", 25.);
  return 0;
}

shows that printf uses both 1 bit and 2 bits for the integer part before the 'p'
(which seems inconsistent).  My guess is it depends upon rounding up.
Comment 1 Andreas Schwab 2019-07-09 13:38:54 UTC
The only requirement is that there is a single nonzero digit before the hexadecimal point.