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

llvm-svn: 271897
This commit is contained in:
Marshall Clow 2016-06-06 14:35:22 +00:00
parent 79c76101ce
commit 3a407a096c
1 changed files with 13 additions and 8 deletions

View File

@ -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', '~'));
}