+2015-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/65709
+ * ubsan.c (instrument_mem_ref): Use TREE_TYPE (base) instead of
+ TREE_TYPE (TREE_TYPE (t)).
+
2015-04-09 Vladimir Makarov <vmakarov@redhat.com>
PR target/65710
+2015-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/65709
+ * c-c++-common/ubsan/align-9.c: New test.
+
2013-04-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/56852
- * gfortran.dg/pr56852.f90 : New test
+ * gfortran.dg/pr56852.f90: New test.
2015-04-09 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
--- /dev/null
+/* Limit this to known non-strict alignment targets. */
+/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */
+/* { dg-options "-O2 -fsanitize=alignment -fsanitize-recover=alignment" } */
+
+__attribute__((noinline, noclone)) void
+foo (void *p, const void *q)
+{
+ *(long int *) p = *(const long int *) q;
+}
+
+int
+main ()
+{
+ struct S { long c; char f[64]; char d; char e[2 * sizeof (long)]; char g[64]; } s;
+ __builtin_memset (&s, '\0', sizeof s);
+ foo (&s.e[0], &s.e[sizeof (long)]);
+ return 0;
+}
+
+/* { dg-output "\.c:8:\[0-9]*: \[^\n\r]*load of misaligned address 0x\[0-9a-fA-F]* for type 'const long int', which requires \[48] byte alignment.*" } */
+/* { dg-output "\.c:8:\[0-9]*: \[^\n\r]*store to misaligned address 0x\[0-9a-fA-F]* for type 'long int', which requires \[48] byte alignment" } */
tree t = TREE_OPERAND (base, 0);
if (!POINTER_TYPE_P (TREE_TYPE (t)))
return;
- if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_TYPE (t))) && mem != base)
+ if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (base)) && mem != base)
ikind = UBSAN_MEMBER_ACCESS;
- tree kind = build_int_cst (TREE_TYPE (t), ikind);
+ tree kind = build_int_cst (build_pointer_type (TREE_TYPE (base)), ikind);
tree alignt = build_int_cst (pointer_sized_int_node, align);
gcall *g = gimple_build_call_internal (IFN_UBSAN_NULL, 3, t, kind, alignt);
gimple_set_location (g, gimple_location (gsi_stmt (*iter)));