Bug 54167 - excessive alignment
Summary: excessive alignment
Status: RESOLVED DUPLICATE of bug 61296
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2012-08-03 15:03 UTC by Ulrich Drepper
Modified: 2021-09-12 07:47 UTC (History)
0 users

See Also:
Host:
Target: x86_64
Build:
Known to work: 4.4.7, 4.9.0
Known to fail: 4.5.0, 4.8.5
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Drepper 2012-08-03 15:03:04 UTC
Compile the following code:

struct c
{
  int a, b;
  /*constexpr*/ c() : a(1), b(2) { }
};

c v;


The variable v will be defined with:

	.bss
	.align 16
	.type	v, @object
	.size	v, 8
v:
	.zero	8

The variable has alignment 16!

If you uncomment the constexpr and compile with -std=gnu++11 it can be seen that the compiler does know what the correct alignment is:

	.globl	v
	.data
	.align 4
	.type	v, @object
	.size	v, 8
v:
	.long	1
	.long	2


This happens with the current svn version as well as with 4.7.0.
Comment 1 Andrew Pinski 2021-09-12 07:47:18 UTC
In GCC 4.9.0 we produce:

        .align 4
        .type   v, @object
        .size   v, 8
v:
        .zero   8

While in GCC 5+, GCC produces:
        .align 8
        .type   v, @object
        .size   v, 8
v:
        .zero   8


The GCC 4.9.0 change was r0-127682.
The GCC 5 change was r5-5887.

Which makes this a dup of bug 61296.

*** This bug has been marked as a duplicate of bug 61296 ***