- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: printf bug with '0' flag under HP-UX 11.11
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 09:10 AM
04-01-2020 09:10 AM
With printf under HP-UX 11.11 (hppa2.0w-hp-hpux11.11), the '0' flag is ignored when a negative precision argument is given, such as in
printf ("%05.*d\n", -1, 1);
The expected output is "00001", but under HP-UX, one does not get the 0's.
ISO C99 says in 7.19.6.1 ("The fprintf function"):
#5 A negative precision argument is taken as if the precision were omitted.
#6 For d, i, o, u, x, and X conversions, if a precision is specified, the 0 flag is ignored.
Note the difference between "precision" and "precision argument".
The reason of the above rule is that if a precision is specified, the number of leading 0's is already implied by the precision. Without this rule, there would be an inconsistency.
HP-UX seems to assume that a negative precision argument is like a given precision, thus ignores the '0' flag. But there are no reasons to ignore the '0' flag in this case: there is no explicit precision that fixes the number of leading 0's. Glibc (Linux), FreeBSD, NetBSD, OpenBSD and AIX all behave correctly.
This yields an error in the MPFR test suite.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 03:37 PM
04-01-2020 03:37 PM
Solution> With printf under HP-UX 11.11 (hppa2.0w-hp-hpux11.11), [...]
Yup. But you might have missed the window where anyone cares:
https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf
> [...] all behave correctly.
its $ cc /version
HP C V7.3-020 on OpenVMS IA64 V8.4
its $ cc of
its $ link of
its $ run of
00001