This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug tree-optimization/49413] over-optimization that causes valid code to segfault


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49413

Gabriel M. Beddingfield <gabriel at teuton dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gabriel at teuton dot org

--- Comment #8 from Gabriel M. Beddingfield <gabriel at teuton dot org> 2011-08-04 03:59:01 UTC ---
I ran into the same problem (gcc 4.5.2, Ubuntu 11.04, x86 Core Duo). 
Unfortunately, it looks like Mr. Pinski is right.

I don't have a copy of the C99 spec, but I do have the C++ 2003 spec.  It says
that alignment requirements are implementation-defined.  In 3.9.2 it says
"Pointers to cv-qualified and cv-unqualified versions (3.9.3) of
layout-compatible types shall have the same value representation and alignment
requirements(3.9)."  I'm sure C99 has a similar requirement.

I.e. since a `double` is required to be 8-byte aligned, so is a valid
`double*`.  Unfortunately, this means that:

   double *ra = malloc(512*sizeof(double));

...can return an invalid (unaligned) array.

However, on most archs I'm pretty sure the optimizer already checks alignment
in order to do things like SIMD instructions.  So this is probably a valid
FEATURE REQUEST... that the optimizer supports (but not necc. optimize)
pointers with arbitrary alignment.


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