Menu

#2309 mingwrt-3.22: printf() no longer honours field width specifications

WSL
closed
regression (8)
Bug
fixed
IINR_-_Include_In_Next_Release
False
2016-08-02
2016-07-21
No

The changes introduced in mingwrt-3.22, to add support for the POSIX "%n$*m$..." style of format specification, appear to interfere with the interpretation of field width and precision specifications, when expressed directly within the format string; indirect "*", or "*.*" references still work, but directly specified values seem to be entirely ignored, for all conversion types.

This defect was observed, when evaluating the test case specified for issue [#2307], (after identification of a solution to that issue, incorrect formatting of the printed test values was apparent -- specifically, the expected initial padding zeros were missing); i.e. on running this program:

#define _XOPEN_SOURCE 700

#include <stdio.h>
#include <winioctl.h>

int main()
{ printf( "IOCTL_STORAGE_EJECT_MEDIA = %1$08d (0x%1$08X)\n",
      IOCTL_STORAGE_EJECT_MEDIA
    );
  return 0;
}

the expected output is:

IOCTL_STORAGE_EJECT_MEDIA = 02967560 (0x002D4808)

but the observed output is:

IOCTL_STORAGE_EJECT_MEDIA = 2967560 (0x2D4808)

Related

Issues: #2280
Issues: #2307
Issues: #2315

Discussion

  • Keith Marshall

    Keith Marshall - 2016-07-24
    • status: assigned --> closed
    • Resolution: none --> fixed
    • Category: Unknown --> IINR_-_Include_In_Next_Release
     
  • Keith Marshall

    Keith Marshall - 2016-07-24

    Issue resulted from incorrect handling of the initial PFORMAT_IGNORE (i.e. -1) values, for the field width and precision specifications, after factoring out of a fast multiply by ten and accumulate function, (__imul10plus()), for shared internal use in computing assigned field width, precision, and positional argument index specifications. This is fixed by commit [7a511c], with subsequent optimization in commit [76be37].

     

    Related

    Commit: [76be37]
    Commit: [7a511c]


    Last edit: Keith Marshall 2016-07-24
  • Keith Marshall

    Keith Marshall - 2016-08-02

    Resolution of this bug is now included in recently published mingwrt-3.22.1.

     
MongoDB Logo MongoDB