www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17685] New: DMD 2.060 regression: align is not respected for


          Issue ID: 17685
           Summary: DMD 2.060 regression: align is not respected for
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: clugdbug yahoo.com.au

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 {
       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:


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.

Jul 25 2017