This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
BUG: %lc in printf fails
- To: libc-alpha at sources dot redhat dot com
- Subject: BUG: %lc in printf fails
- From: Markus Kuhn <Markus dot Kuhn at cl dot cam dot ac dot uk>
- Date: Sat, 23 Sep 2000 18:02:12 +0100
- cc: gcc at gcc dot gnu dot org
BUG REPORT (glibc and gcc)
With a recent glibc 2.1.93 CVS snapshot and gcc 2.95.2 on Linux,
the test program
---------------------------------------------------------------
#define _XOPEN_SOURCE
#include <stdio.h>
#include <wchar.h>
int main() {
wint_t c = L'ü';
printf("wcwidth(L'%lc') = %d\n", c, wcwidth(c));
return 0;
}
---------------------------------------------------------------
produces the unexpected output
---------------------------------------------------------------
wcwidth(L'---------------------------------------------------------------
as opposed to the expected output
---------------------------------------------------------------
wcwidth(L'ue') = 2
---------------------------------------------------------------
In addition, gcc 2.95.2 complains erroneously
wcwtest.c:9: warning: long int format, int arg (arg 2)
even though %lc should expect a wint_t argument.
From the holy words of ISO/IEC, book 9899:1999(E), verse 7.19.6.1
"The fprintf function", paragraph 7:
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.cl.cam.ac.uk/~mgk25/volatile/ISO-C-FDIS.1999-04.txt
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>