[libcxx] r271897 - Remove arithmetic +/-127 on chars; results in UB when dealing with signed chars. Thanks to STL at microsoft for the report.

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 6 07:35:23 PDT 2016


Author: marshall
Date: Mon Jun  6 09:35:22 2016
New Revision: 271897

URL: http://llvm.org/viewvc/llvm-project?rev=271897&view=rev
Log:
Remove arithmetic +/-127 on chars; results in UB when dealing with signed chars. Thanks to STL at microsoft for the report.

Modified:
    libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp

Modified: libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp?rev=271897&r1=271896&r2=271897&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp Mon Jun  6 09:35:22 2016
@@ -1,6 +1,6 @@
 //===----------------------------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
+//					   The LLVM Compiler Infrastructure
 //
 // This file is dual licensed under the MIT and the University of Illinois Open
 // Source Licenses. See LICENSE.TXT for details.
@@ -18,11 +18,16 @@
 
 int main()
 {
-    char c = '\0';
-    assert(!std::char_traits<char>::lt('a', 'a'));
-    assert( std::char_traits<char>::lt('A', 'a'));
-    assert(!std::char_traits<char>::lt('A' + 127, 'a'));
-    assert(!std::char_traits<char>::lt('A' - 127, 'a'));
-    assert( std::char_traits<char>::lt('A', 'a' + 127));
-    assert( std::char_traits<char>::lt('A', 'a' - 127));
+	assert( std::char_traits<char>::lt('\0', 'A'));
+	assert(!std::char_traits<char>::lt('A', '\0'));
+
+	assert(!std::char_traits<char>::lt('a', 'a'));
+	assert( std::char_traits<char>::lt('A', 'a'));
+	assert(!std::char_traits<char>::lt('a', 'A'));
+	
+	assert( std::char_traits<char>::lt('a', 'z'));
+	assert( std::char_traits<char>::lt('A', 'Z'));
+
+	assert( std::char_traits<char>::lt(' ', 'A'));
+	assert( std::char_traits<char>::lt('A', '~'));
 }




More information about the cfe-commits mailing list