Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment for nested typedef incorrect #332

Closed
Tracked by #387
TwoClocks opened this issue Jul 7, 2022 · 1 comment
Closed
Tracked by #387

Alignment for nested typedef incorrect #332

TwoClocks opened this issue Jul 7, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@TwoClocks
Copy link
Contributor

TwoClocks commented Jul 7, 2022

typedef int I1 __attribute__((aligned(8)));
typedef I1 I2 __attribute__((aligned(1)));

_Static_assert(sizeof(I2) == 4,"record I2 wrong sizeof");
_Static_assert(_Alignof(I2) == 1, "record I2 wrong alignment");

the alignment of I2 fails. It returns 8. It should be one.

It looks like I2 has I1 attributes as well as its own. Seems like typedefs "roll up" attributes of the types they refer to.

typedef: 'attributed(int)'
attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 8 }
name: I1

typedef: 'attributed(int)'
attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 8 }
attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 1 }
name: I2

@Vexu Vexu added enhancement New feature or request labels Jul 7, 2022
@TwoClocks
Copy link
Contributor Author

Some more info on this. It looks like I2 has I1 attributes as well as it's own. I think this is the main issue.

typedef: 'attributed(int)'
 attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 8 }
 name: I1

typedef: 'attributed(int)'
 attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 8 }
 attr: aligned alignment: Attribute.Alignment{ .node = Tree.NodeIndex.none, .requested = 1 }
 name: I2

@Vexu Vexu added bug Something isn't working and removed enhancement New feature or request labels Sep 9, 2022
TwoClocks added a commit to TwoClocks/arocc that referenced this issue Sep 12, 2022
@Vexu Vexu closed this as completed in b4def26 Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants