summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C15
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/charset.c2
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 31bcf5cd683..888c5964c9f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-29 Joseph Myers <joseph@codesourcery.com>
+
+ PR preprocessor/41698
+ * gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C: New test.
+
2014-11-28 Vladimir Makarov <vmakarov@redhat.com>
PR target/64061
diff --git a/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C b/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C
new file mode 100644
index 00000000000..e60f25b52a4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C
@@ -0,0 +1,15 @@
+// PR 41698: off-by-one error in UTF-16 encoding.
+
+// { dg-do run { target c++11 } }
+
+extern "C" void abort (void);
+extern "C" void exit (int);
+
+int
+main ()
+{
+ char16_t s[] = u"\uffff";
+ if (sizeof s != 2 * sizeof (char16_t) || s[0] != 0xffff || s[1] != 0)
+ abort ();
+ exit (0);
+}
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index e04130a8df7..f9a04f9376e 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-29 John Schmerge <jbschmerge@gmail.com>
+
+ PR preprocessor/41698
+ * charset.c (one_utf8_to_utf16): Do not produce surrogate pairs
+ for 0xffff.
+
2014-11-25 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/60436
diff --git a/libcpp/charset.c b/libcpp/charset.c
index 1064f527633..a34dafbb194 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -353,7 +353,7 @@ one_utf8_to_utf16 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
return EILSEQ;
}
- if (s < 0xFFFF)
+ if (s <= 0xFFFF)
{
if (*outbytesleftp < 2)
{