public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t
@ 2023-07-06 21:59 bruno at clisp dot org
  2023-07-06 22:00 ` [Bug string/30620] " bruno at clisp dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-07-06 21:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

            Bug ID: 30620
           Summary: wcscmp bug on platforms with unsigned wchar_t
           Product: glibc
           Version: 2.28
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: bruno at clisp dot org
  Target Milestone: ---

Created attachment 14956
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14956&action=edit
test case testt-wcscmp.c

When we have two wide-character strings such that wcscmp (input1, input2) < 0,
obviously we should have wcscmp (input2, input1) > 0. This is not the case on
glibc on platforms which have an unsigned 'wchar_t' type (such as aarch64).

On platforms with a signed 'wchar_t' type (such as alpha), there is no problem.

How to reproduce: On a Linux/aarch64 machine, such as gcc185.fsffrance.org, run
the attached program:
$ gcc test-wcscmp.c
$ ./a.out 

Expected behaviour: Successful termination.

Actual behaviour:
test-wcscmp.c:107: assertion 'wcscmp (input2, input1) > 0' failed
Aborted (core dumped)

The problematic source code appears to be in the file glibc/wcsmbs/wcscmp.c .

The function wcsncmp, OTOH, works fine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
@ 2023-07-06 22:00 ` bruno at clisp dot org
  2023-07-06 22:43 ` bruno at clisp dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-07-06 22:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

Bruno Haible <bruno at clisp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |aarch64-unknown-linux
              Build|                            |aarch64-unknown-linux
               Host|                            |aarch64-unknown-linux

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
  2023-07-06 22:00 ` [Bug string/30620] " bruno at clisp dot org
@ 2023-07-06 22:43 ` bruno at clisp dot org
  2023-07-07  8:23 ` schwab@linux-m68k.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-07-06 22:43 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #1 from Bruno Haible <bruno at clisp dot org> ---
Likewise on 32-bit ARM platforms (arm*-unknown-linux).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
  2023-07-06 22:00 ` [Bug string/30620] " bruno at clisp dot org
  2023-07-06 22:43 ` bruno at clisp dot org
@ 2023-07-07  8:23 ` schwab@linux-m68k.org
  2023-07-07  9:12 ` bruno at clisp dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: schwab@linux-m68k.org @ 2023-07-07  8:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
The cited paragraph only defines the relation of two wide characters, not
arbitrary wchar_t values.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
                   ` (2 preceding siblings ...)
  2023-07-07  8:23 ` schwab@linux-m68k.org
@ 2023-07-07  9:12 ` bruno at clisp dot org
  2023-07-07  9:45 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-07-07  9:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #3 from Bruno Haible <bruno at clisp dot org> ---
(In reply to Andreas Schwab from comment #2)
> The cited paragraph only defines the relation of two wide characters, not
> arbitrary wchar_t values.

ISO C 17 § 3.7.3 specifies that every wchar_t value is a "wide character".

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
                   ` (3 preceding siblings ...)
  2023-07-07  9:12 ` bruno at clisp dot org
@ 2023-07-07  9:45 ` schwab@linux-m68k.org
  2023-07-07 10:01 ` bruno at clisp dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: schwab@linux-m68k.org @ 2023-07-07  9:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
No, it only says that every wide character is representable as a wchar_t value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
                   ` (4 preceding siblings ...)
  2023-07-07  9:45 ` schwab@linux-m68k.org
@ 2023-07-07 10:01 ` bruno at clisp dot org
  2023-07-07 10:11 ` schwab@linux-m68k.org
  2023-07-18 15:57 ` joseph at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-07-07 10:01 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #5 from Bruno Haible <bruno at clisp dot org> ---
The musl libc people recognize that wcscmp has to work on arbitrary wchar_t
values:
http://git.musl-libc.org/cgit/musl/commit/?id=07616721f1fa6cb215ffbef23441cae80412484f
https://www.openwall.com/lists/musl/2023/01/06/3

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
                   ` (5 preceding siblings ...)
  2023-07-07 10:01 ` bruno at clisp dot org
@ 2023-07-07 10:11 ` schwab@linux-m68k.org
  2023-07-18 15:57 ` joseph at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: schwab@linux-m68k.org @ 2023-07-07 10:11 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #6 from Andreas Schwab <schwab@linux-m68k.org> ---
But that's only a QoI issue.  You cannot argue with the standard if it doesn't
say anything.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug string/30620] wcscmp bug on platforms with unsigned wchar_t
  2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
                   ` (6 preceding siblings ...)
  2023-07-07 10:11 ` schwab@linux-m68k.org
@ 2023-07-18 15:57 ` joseph at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2023-07-18 15:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30620

--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
I think the relevant wording is the general wording for wchar.h: 
"Arguments to the functions in this subclause may point to arrays 
containing wchar_t values that do not correspond to members of the 
extended character set. Such values shall be processed according to the 
specified semantics, except that it is unspecified whether an encoding 
error occurs if such a value appears in the format string [...]".

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-18 15:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 21:59 [Bug string/30620] New: wcscmp bug on platforms with unsigned wchar_t bruno at clisp dot org
2023-07-06 22:00 ` [Bug string/30620] " bruno at clisp dot org
2023-07-06 22:43 ` bruno at clisp dot org
2023-07-07  8:23 ` schwab@linux-m68k.org
2023-07-07  9:12 ` bruno at clisp dot org
2023-07-07  9:45 ` schwab@linux-m68k.org
2023-07-07 10:01 ` bruno at clisp dot org
2023-07-07 10:11 ` schwab@linux-m68k.org
2023-07-18 15:57 ` joseph at codesourcery dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).