This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR middle-end/29111

It's the failure of gcc.dg/torture/pr26565.c at -O0 on PA and SPARC machines, 
a regression from the 3.4 series of compilers.

struct timeval {
    long tv_sec;

struct outdata {
    long align;
    char seq;
    struct timeval tv __attribute__((packed));

void send_probe(struct outdata *outdata, struct timeval *tp)
    memcpy(&outdata->tv, tp, sizeof outdata->tv);

The memcpy is optimized into unaligned stores, hence SIGBUS at runtime.

According to Richard ( 
it is not possible to compute accurate alignment information for pointers 
without running TER so memcpy should not be optimized in that case.

Tested on sparc-sun-solaris2.10.  OK for mainline?

2006-10-14  Eric Botcazou  <>
            John David Anglin ?<>
            Andrew Pinski  <>

	PR middle-end/29111
	* builtins.c (get_pointer_alignment): Return 0 if TER is not run.

Eric Botcazou
Index: builtins.c
--- builtins.c	(revision 117595)
+++ builtins.c	(working copy)
@@ -235,6 +235,10 @@ get_pointer_alignment (tree exp, unsigne
   if (! POINTER_TYPE_P (TREE_TYPE (exp)))
     return 0;
+  /* We rely on TER to compute accurate alignment information.  */
+  if (!(optimize && flag_tree_ter))
+    return 0;
   align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
   align = MIN (align, max_align);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]