#47 Remove invalid MSVCRT correction of 'l' modifer.

closed-fixed
nobody
CRT (12)
5
2012-01-19
2012-01-16
No

Moved from Bugs. https://sourceforge.net/tracker/?func=detail&aid=3473599&group_id=202880&atid=983354

mingw-w64-crt/stdio/mingw_pformat.c treats 'l' as long double under the guise of MSVCRT compatibility.

I feel this is incorrect for the following reasons:

1. MSVCRT treats long double as double. So __pformat should not need to treat 'l' as long double.
2. __pformat is used for C99 compatibility within MinGW. Supporting MSVCRT conventions should be avoided.
3. The snippet below produces incorrect output when using __pformat via -D__USE_MINGW_ANSI_STDIO.

/*
MSVCRT: gcc -o pformat.exe pformat.c
Outputs: 12.00000

C99: gcc -o pformat.exe pformat.c -D__USE_MINGW_ANSI_STDIO
Outputs: 0.000000
*/
#include <stdio.h>

main()
{
double a = 12;
printf("%lf", a);
}

Discussion

  • Daniel Green

    Daniel Green - 2012-01-16

    Remove invalid MSVCRT correction of 'l' modifer.

     
  • Kai Tietz

    Kai Tietz - 2012-01-17
    • status: open --> closed-invalid
     
  • Kai Tietz

    Kai Tietz - 2012-01-17

    POSIX printf is there for explicit support 'long double' type for gcc. And for gcc it is a 80-bit floating-point and not a 64-bit as for VC.

    Therefore invalid

     
  • Kai Tietz

    Kai Tietz - 2012-01-17
    • status: closed-invalid --> open-accepted
     
  • Kai Tietz

    Kai Tietz - 2012-01-17

    Sorry, for the misunderstanding. You are right C99 specification (7.19.6.1 The fprintf function) explict says, that 'l' shall be ignored for floating-point output.

    Thank you for keeping on it.

    Kai

     
  • Daniel Green

    Daniel Green - 2012-01-17

    From the C99 spec p 276.

    l (ell)
    Specifies that a following 'd', 'i', 'o', 'u', 'x', or 'X' conversion specifier applies to a 'long int' or 'unsigned long int' argument; that a following 'n' conversion specifier applies to a pointer to a 'long int' argument; that a following 'c' conversion specifier applies to a 'wint_t' argument; that a following 's' conversion specifier applies to a pointer to a 'wchar_t' argument; or has no effect on a following a, A, e, E, f, F, g, or G conversion specifier.

    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf

     
  • Kai Tietz

    Kai Tietz - 2012-01-17

    Could you provide me a ChangeLog entry for this patch? (classical gnu-style)

    Thanks

     
  • Daniel Green

    Daniel Green - 2012-01-17

    2012-01-17 Daniel Green <venix1@gmail.com>

    * mingw-w64-crt/stdio/mingw_pformat.c (__pformat): Correct 'l' length modifier
    to follow C99 specification (7.19.6.1) with Windows.

     
  • Kai Tietz

    Kai Tietz - 2012-01-17

    Thanks, patch is committed at revision 4742 to trunk. Set state to pending, as maybe Ozkan want to apply this patch for 2.x branch, too.

     
  • Kai Tietz

    Kai Tietz - 2012-01-17
    • status: open-accepted --> pending-fixed
     
  • Ozkan Sezer

    Ozkan Sezer - 2012-01-19
    • status: pending-fixed --> closed-fixed
     
  • Ozkan Sezer

    Ozkan Sezer - 2012-01-19

    Done: applied the change to v1.x at rev.4748 and to v2.x at rev.4749.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks