diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr77718.c | 25 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 355148b..d561652 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2016-11-09 Jakub Jelinek <jakub@redhat.com> + PR target/77718 + * builtins.c (expand_builtin_memcmp): Formatting fix. + * flag-types.h (enum sanitize_code): Add SANITIZE_SHIFT_BASE and SANITIZE_SHIFT_EXPONENT, change SANITIZE_SHIFT to bitwise or of them, renumber other enumerators. @@ -5059,7 +5062,8 @@ 2016-09-29 Bernd Schmidt <bschmidt@redhat.com> - * builtins.c (expand_builtin_memcmp): don't swap args unless + PR target/77718 + * builtins.c (expand_builtin_memcmp): Don't swap args unless result is only being compared with zero. 2016-09-29 Marek Polacek <polacek@redhat.com> diff --git a/gcc/builtins.c b/gcc/builtins.c index cc711a0..3ac2d44 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -3754,7 +3754,7 @@ expand_builtin_memcmp (tree exp, rtx target, bool result_eq) { src_str = c_getstr (arg1); if (src_str != NULL) - std::swap (arg1_rtx, arg2_rtx); + std::swap (arg1_rtx, arg2_rtx); } /* If SRC is a string constant and block move would be done diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dd221bb..7a3b6c5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-11-09 Jakub Jelinek <jakub@redhat.com> + PR target/77718 + * gcc.c-torture/execute/pr77718.c: New test. + * gcc.dg/ubsan/c99-shift-3.c: New test. * gcc.dg/ubsan/c99-shift-4.c: New test. * gcc.dg/ubsan/c99-shift-5.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr77718.c b/gcc/testsuite/gcc.c-torture/execute/pr77718.c new file mode 100644 index 0000000..a76effe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr77718.c @@ -0,0 +1,25 @@ +/* PR middle-end/77718 */ + +char a[64] __attribute__((aligned (8))); + +__attribute__((noinline, noclone)) int +foo (void) +{ + return __builtin_memcmp ("bbbbbb", a, 6); +} + +__attribute__((noinline, noclone)) int +bar (void) +{ + return __builtin_memcmp (a, "bbbbbb", 6); +} + +int +main () +{ + __builtin_memset (a, 'a', sizeof (a)); + if (((foo () < 0) ^ ('a' > 'b')) + || ((bar () < 0) ^ ('a' < 'b'))) + __builtin_abort (); + return 0; +} |