public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60397] New: The value of char16_t u'\uffff' is 0xdfff instead of 0xffff
@ 2014-03-03  4:48 wjl at icecavern dot net
  2015-06-21 17:17 ` [Bug c++/60397] " wjl at icecavern dot net
  0 siblings, 1 reply; 2+ messages in thread
From: wjl at icecavern dot net @ 2014-03-03  4:48 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 10662 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60397

            Bug ID: 60397
           Summary: The value of char16_t u'\uffff' is 0xdfff instead of
                    0xffff
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wjl at icecavern dot net
                CC: daniel.kruegler at googlemail dot com

Created attachment 32247
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32247&action=edit
uffff.c++ -- program that shows the problem

+++ This bug was initially created as a clone of Bug #59873 +++

I found another major bug with char16_t literals when trying to encode a
U+FFFF.

1) A incorrect warning is emitted.
2) The value is incorrectly changed from U+FFFF to U+DFFF (a low surrogate).

This is very similar to, but different that, bug #59873. Because this problem
seems related, I've shown both the U+FFFF and U+0000 problem in the provided
example code that triggers the bug. Notice that they fail in similar, but
different, ways.

(For reference to those who care about other compilers, none of these problems
appear using clang 3.5.)

The following demonstrates the problem with both g++ 4.8.2 (released) and g++
4.9.0 (trunk):

# First with g++ 4.8.2

$ g++ --version
g++ (Debian 4.8.2-14) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ -std=c++11 uffff.c++
uffff.c++:3:16: warning: character constant too long for its type [enabled by
default]
  static_assert(u'\uffff'        == 0xffff, "FAILS");
                ^
uffff.c++:7:16: warning: character constant too long for its type [enabled by
default]
  static_assert(u'\U0000ffff'    == 0xffff, "FAILS");
                ^
uffff.c++:19:16: warning: character constant too long for its type [enabled by
default]
  static_assert(u'\uffff'        != 0xdfff, "FAILS");
                ^
uffff.c++:21:16: warning: character constant too long for its type [enabled by
default]
  static_assert(u'\U0000ffff'    != 0xdfff, "FAILS");
                ^
uffff.c++: In function ‘int main()’:
uffff.c++:3:2: error: static assertion failed: FAILS
  static_assert(u'\uffff'        == 0xffff, "FAILS");
  ^
uffff.c++:7:2: error: static assertion failed: FAILS
  static_assert(u'\U0000ffff'    == 0xffff, "FAILS");
  ^
uffff.c++:11:2: error: static assertion failed: FAILS
  static_assert(u"\uffff"[0]     == 0xffff, "FAILS");
  ^
uffff.c++:15:2: error: static assertion failed: FAILS
  static_assert(u"\U0000ffff"[0] == 0xffff, "FAILS");
  ^
uffff.c++:19:2: error: static assertion failed: FAILS
  static_assert(u'\uffff'        != 0xdfff, "FAILS");
  ^
uffff.c++:21:2: error: static assertion failed: FAILS
  static_assert(u'\U0000ffff'    != 0xdfff, "FAILS");
  ^
uffff.c++:28:2: error: static assertion failed: FAILS
  static_assert(u'\u0000'        == 0x0000, "FAILS");
  ^
uffff.c++:30:2: error: static assertion failed: FAILS
  static_assert(U'\u0000'        == 0x0000, "FAILS");
  ^
uffff.c++:32:2: error: static assertion failed: FAILS
  static_assert(u'\U00000000'    == 0x0000, "FAILS");
  ^
uffff.c++:34:2: error: static assertion failed: FAILS
  static_assert(U'\U00000000'    == 0x0000, "FAILS");
  ^
uffff.c++:36:2: error: static assertion failed: FAILS
  static_assert(u"\u0000"[0]     == 0x0000, "FAILS");
  ^
uffff.c++:38:2: error: static assertion failed: FAILS
  static_assert(U"\u0000"[0]     == 0x0000, "FAILS");
  ^
uffff.c++:40:2: error: static assertion failed: FAILS
  static_assert(u"\U00000000"[0] == 0x0000, "FAILS");
  ^
uffff.c++:42:2: error: static assertion failed: FAILS
  static_assert(U"\U00000000"[0] == 0x0000, "FAILS");
  ^
uffff.c++:45:2: error: static assertion failed: FAILS
  static_assert(u'\u0000'        != 0x0001, "FAILS");
  ^
uffff.c++:46:2: error: static assertion failed: FAILS
  static_assert(U'\u0000'        != 0x0001, "FAILS");
  ^
uffff.c++:47:2: error: static assertion failed: FAILS
  static_assert(u'\U00000000'    != 0x0001, "FAILS");
  ^
uffff.c++:48:2: error: static assertion failed: FAILS
  static_assert(U'\U00000000'    != 0x0001, "FAILS");
  ^
uffff.c++:49:2: error: static assertion failed: FAILS
  static_assert(u"\u0000"[0]     != 0x0001, "FAILS");
  ^
uffff.c++:50:2: error: static assertion failed: FAILS
  static_assert(U"\u0000"[0]     != 0x0001, "FAILS");
  ^
uffff.c++:51:2: error: static assertion failed: FAILS
  static_assert(u"\U00000000"[0] != 0x0001, "FAILS");
  ^
uffff.c++:52:2: error: static assertion failed: FAILS
  static_assert(U"\U00000000"[0] != 0x0001, "FAILS");
  ^

# Change to g++ 4.9.0

$ g++ --version
g++ (Debian 4.9-20140218-1) 4.9.0 20140218 (experimental) [trunk revision
207856]
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ -std=c++11 uffff.c++ 2>&1
uffff.c++:3:16: warning: character constant too long for its type
  static_assert(u'\uffff'        == 0xffff, "FAILS");
                ^
uffff.c++:7:16: warning: character constant too long for its type
  static_assert(u'\U0000ffff'    == 0xffff, "FAILS");
                ^
uffff.c++:19:16: warning: character constant too long for its type
  static_assert(u'\uffff'        != 0xdfff, "FAILS");
                ^
uffff.c++:21:16: warning: character constant too long for its type
  static_assert(u'\U0000ffff'    != 0xdfff, "FAILS");
                ^
uffff.c++: In function ‘int main()’:
uffff.c++:3:2: error: static assertion failed: FAILS
  static_assert(u'\uffff'        == 0xffff, "FAILS");
  ^
uffff.c++:7:2: error: static assertion failed: FAILS
  static_assert(u'\U0000ffff'    == 0xffff, "FAILS");
  ^
uffff.c++:11:2: error: static assertion failed: FAILS
  static_assert(u"\uffff"[0]     == 0xffff, "FAILS");
  ^
uffff.c++:15:2: error: static assertion failed: FAILS
  static_assert(u"\U0000ffff"[0] == 0xffff, "FAILS");
  ^
uffff.c++:19:2: error: static assertion failed: FAILS
  static_assert(u'\uffff'        != 0xdfff, "FAILS");
  ^
uffff.c++:21:2: error: static assertion failed: FAILS
  static_assert(u'\U0000ffff'    != 0xdfff, "FAILS");
  ^
uffff.c++:28:2: error: static assertion failed: FAILS
  static_assert(u'\u0000'        == 0x0000, "FAILS");
  ^
uffff.c++:30:2: error: static assertion failed: FAILS
  static_assert(U'\u0000'        == 0x0000, "FAILS");
  ^
uffff.c++:32:2: error: static assertion failed: FAILS
  static_assert(u'\U00000000'    == 0x0000, "FAILS");
  ^
uffff.c++:34:2: error: static assertion failed: FAILS
  static_assert(U'\U00000000'    == 0x0000, "FAILS");
  ^
uffff.c++:36:2: error: static assertion failed: FAILS
  static_assert(u"\u0000"[0]     == 0x0000, "FAILS");
  ^
uffff.c++:38:2: error: static assertion failed: FAILS
  static_assert(U"\u0000"[0]     == 0x0000, "FAILS");
  ^
uffff.c++:40:2: error: static assertion failed: FAILS
  static_assert(u"\U00000000"[0] == 0x0000, "FAILS");
  ^
uffff.c++:42:2: error: static assertion failed: FAILS
  static_assert(U"\U00000000"[0] == 0x0000, "FAILS");
  ^
uffff.c++:45:2: error: static assertion failed: FAILS
  static_assert(u'\u0000'        != 0x0001, "FAILS");
  ^
uffff.c++:46:2: error: static assertion failed: FAILS
  static_assert(U'\u0000'        != 0x0001, "FAILS");
  ^
uffff.c++:47:2: error: static assertion failed: FAILS
  static_assert(u'\U00000000'    != 0x0001, "FAILS");
  ^
uffff.c++:48:2: error: static assertion failed: FAILS
  static_assert(U'\U00000000'    != 0x0001, "FAILS");
  ^
uffff.c++:49:2: error: static assertion failed: FAILS
  static_assert(u"\u0000"[0]     != 0x0001, "FAILS");
  ^
uffff.c++:50:2: error: static assertion failed: FAILS
  static_assert(U"\u0000"[0]     != 0x0001, "FAILS");
  ^
uffff.c++:51:2: error: static assertion failed: FAILS
  static_assert(u"\U00000000"[0] != 0x0001, "FAILS");
  ^
uffff.c++:52:2: error: static assertion failed: FAILS
  static_assert(U"\U00000000"[0] != 0x0001, "FAILS");
  ^
>From gcc-bugs-return-445268-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Mar 03 04:50:16 2014
Return-Path: <gcc-bugs-return-445268-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 8505 invoked by alias); 3 Mar 2014 04:50:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 8475 invoked by uid 48); 3 Mar 2014 04:50:12 -0000
From: "wjl at icecavern dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59873] The value of char32_t U'\u0000' and char16_t u'\u000' is 1, instead of 0.
Date: Mon, 03 Mar 2014 04:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: wjl at icecavern dot net
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-59873-4-asR8U0V4mh@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59873-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59873-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg00137.txt.bz2
Content-length: 454

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY873

--- Comment #10 from Wesley J. Landaker <wjl at icecavern dot net> ---
Created attachment 32248
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2248&actioníit
uffff.c++ -- program that shows this problem, and bug #60397's problem

I opened new bug #60397 that is a similar issue, but not the same problem. I've
attached a new program that more simply shows the problem just using
static_assert.


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

* [Bug c++/60397] The value of char16_t u'\uffff' is 0xdfff instead of 0xffff
  2014-03-03  4:48 [Bug c++/60397] New: The value of char16_t u'\uffff' is 0xdfff instead of 0xffff wjl at icecavern dot net
@ 2015-06-21 17:17 ` wjl at icecavern dot net
  0 siblings, 0 replies; 2+ messages in thread
From: wjl at icecavern dot net @ 2015-06-21 17:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60397

Wesley J. Landaker <wjl at icecavern dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |5.1.1
         Resolution|---                         |FIXED

--- Comment #1 from Wesley J. Landaker <wjl at icecavern dot net> ---
I can confirm that this is fixed in GCC 5.1.1.

The issue from bug #59873 and bug #53690, also demonstrated in the attached
code, is still broken in GCC 5.1.1.


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

end of thread, other threads:[~2015-06-21 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-03  4:48 [Bug c++/60397] New: The value of char16_t u'\uffff' is 0xdfff instead of 0xffff wjl at icecavern dot net
2015-06-21 17:17 ` [Bug c++/60397] " wjl at icecavern dot net

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).