wcwidth broken with gcc 16

Thomas Wolff via Cygwin <[email protected]> Sun, 12 Apr 2026 13:25:07 +0200
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
Observed with gcc 16:
For a number of character ranges, mainly (but not only) from CJK ranges, 
wcwidth incorrectly reports width 1 instead of 2, 0, or -1.
Test file attached.
I am puzzled as I see no cause of this behaviour, no define or typedef 
that might divert from newlib/libc wcwidth, and that would clearly 
deliver the proper values.
Thomas


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
wcwidth-test.c (text/plain, 782 B)
#define _GNU_SOURCE 1
#include <locale.h>
#include <wchar.h>

#include <stdio.h>


#define showtypewidth(T)	printf("%d %s\n", sizeof(T), #T)


void showwidth (unsigned int c)
{
  printf ("%d U+%04X\n", wcwidth (c), c);
}

void showrange (unsigned int low, unsigned int high)
{
  showwidth (low);
  showwidth (high);
}

void main (int argc, char * * argv)
{
  setlocale (LC_CTYPE, "");

  // only first and last code point of larger ranges are tested
  showrange (0x8000, 0xA4CF);
  showrange (0xA66F, 0xA672);
  showrange (0xA674, 0xA67D);
  showrange (0xA8E0, 0xA8F1);
  showrange (0xAC00, 0xD7C6);
  showrange (0xD7CB, 0xD7FB);
  showrange (0xD800, 0xDFFF);
  showrange (0xF900, 0xFAFF);
  showrange (0xFE00, 0xFE6F);
  showrange (0xFF01, 0xFF60);
  showrange (0xFFE0, 0xFFE6);
}