Bug 1208989 - GCC 5 no longer honors align attribute on complicated typedef
Summary: GCC 5 no longer honors align attribute on complicated typedef
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 22
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1214354
TreeView+ depends on / blocked
 
Reported: 2015-04-04 21:59 UTC by Michael Catanzaro
Modified: 2015-04-29 15:54 UTC (History)
6 users (show)

Fixed In Version: gcc-5.0.1-0.1.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-04-21 18:40:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Preprocessed TransformationMatrix.cpp file (2.78 MB, text/plain)
2015-04-06 10:16 UTC, Žan Doberšek
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 65690 0 None None None Never
WebKit Project 142333 0 None None None Never

Description Michael Catanzaro 2015-04-04 21:59:42 UTC
Description of problem: We're getting some serious crashes in WebKit that were traced to GCC 5 no longer honoring the aligned attribute on a complicated typedef:

typedef double Matrix4[4][4] __attribute__((aligned (16)));

^ That worked in GCC 4.9, but no longer works in GCC 5.0.

Declaring instances of Matrix4 with alignas does work:

alignas(16) Matrix4 m_matrix;

See https://bugs.webkit.org/show_bug.cgi?id=142333#c20 for full details.

Sorry I don't have any sane minimal reproducer (besides "wait four hours for WebKit to compile then visit youtube.com"), as I'm using an F21 machine right now. I'm just reporting this in case you think a bad bug report is better than no report at all. I will mark this bug needinfo on myself as a reminder to try to construct a small reproducer.

Comment 1 Michael Catanzaro 2015-04-05 00:06:40 UTC
(In reply to Michael Catanzaro from comment #0)
> Description of problem: We're getting some serious crashes in WebKit that
> were traced to GCC 5 no longer honoring the aligned attribute on a
> complicated typedef:
> 
> typedef double Matrix4[4][4] __attribute__((aligned (16)));
> 
> ^ That worked in GCC 4.9, but no longer works in GCC 5.0.

Hm, it works in general. This test does NOT demonstrate the bug; it works fine with both versions of GCC so long as the attribute is present on the typedef:

#include <stdio.h>

typedef double Matrix4[4][4] __attribute__((aligned (16)));

struct s
{
  char a, b, c; // random variables to throw off alignment
  Matrix4 m;
};

int
main ()
{
  struct s s;
  Matrix4 m;
  char c; // again just trying to throw off alignment
  Matrix4 mm;

  printf ("Last digit should be 0: %p\n", s.m);
  printf ("Last digit should be 0: %p\n", m);
  printf ("Last digit should be 0: %p\n", mm);

  return 0;
}


So I'm not sure what is causing the problem. I guess the thing to do is try to work backwards from the WebKit code. This will be a pain. :(

Comment 2 Žan Doberšek 2015-04-06 10:16:24 UTC
Created attachment 1011289 [details]
Preprocessed TransformationMatrix.cpp file

Attached is the preprocessed file where the problem manifests.

The Matrix4 type is defined on line 98480.
At the bottom of the file are two static_assert statements that test the alignment of the TransformationMatrix and TransformationMatrix::Matrix4 types, expecting 16 as the result. Both fail when compiling with g++-5 on Debian:

$ g++-5 -std=c++11 -c TransformationMatrix.E.cpp

Comment 3 Michael Catanzaro 2015-04-06 19:09:27 UTC
This looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48138 which suggests there be dragons here, although that doesn't explain what changed between GCC 4.9 and 5.0.

Note "but the core problem seems to be that alignments on typedefs aren't supported" from the upstream bug can't be correct, as http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html introduces the attribute by demonstrating its use on a typedef.

Comment 4 Fedora Update System 2015-04-14 06:58:50 UTC
gcc-5.0.1-0.1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/gcc-5.0.1-0.1.fc22

Comment 5 Fedora Update System 2015-04-21 18:40:18 UTC
gcc-5.0.1-0.1.fc22, libtool-2.4.2-33.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.