Bug 17685 – DMD 2.060 regression: align is not respected for structs

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-07-25T14:14:00Z
Last change time
2017-07-26T10:31:27Z
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2017-07-25T14:14:17Z
Yes, I know this a regression from 5 years ago. But some of us are using compilers from even earlier.... There is a real problem with the behaviour of align(). -------------------- align(1) struct A { align(1): int a; } static assert(A.alignof == 1); // fails, A.alignof is 4 -------------------- In 2.059 and earlier (including D1), that static assert would pass. Note that for a struct which should have the same properties: struct B { ubyte[4] b; } static assert(B.alignof == 1); // ok So the padding is not because of the struct size. The offending commit was made here, with a dreadful commit message: https://github.com/dlang/dmd/commit/20fb83928b12af809798f3fa0247a4d5cdf80e4f Previously in fact this would work even without the outer "align(1)" around the struct. I am not sure what the motivation for that silent breaking language change was, but it does not make any sense to me. It certainly introduces opportunity for subtle, hideous bugs. It's particularly nasty when passing structs to other languages. At the time, there was a bug report on a similar issue which was closed as invalid. https://issues.dlang.org/show_bug.cgi?id=8565 I suspect that was closed rather too hastily.
Comment #1 by ag0aep6g — 2017-07-25T14:32:43Z
Have you checked with 2.075.0? Works for me.
Comment #2 by greeenify — 2017-07-25T15:01:16Z
> Have you checked with 2.075.0? Works for me. Yep, verified with DReg: https://run.dlang.io/gist/4624d3499159997d2f90466bd7409967?compiler=dreg This is Vladimir's tool to run a file against multiple compilers and comparing the output. At the moment run.dlang.io runs 2.060.0 and upwards.
Comment #3 by dlang-bugzilla — 2017-07-26T10:31:27Z
Yep, fixed by https://github.com/dlang/dmd/pull/6754. *** This issue has been marked as a duplicate of issue 17277 ***