Thread overview
[Issue 5482] New: Crash with align(0)
Feb 10, 2011
Don
Mar 02, 2011
Don
January 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5482

           Summary: Crash with align(0)
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-01-25 02:59:10 PST ---
This crashes DMD 2.051:

align(0) struct Foo {
    char c;
    int i;
}
void main() {
    Foo f = Foo();
}


---------------

This causes an Access Violation with DMD 2.051:

align(0) struct Foo {
    int i, j;
}
void main() {
    Foo f = Foo();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5482



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-02-10 12:54:55 PST ---
Cannot reproduce.
The second case gives a runtime access violation, but neither example causes a
compiler segfault.

Is align(0) really valid? I don't think it makes sense. It's definitely illegal on Microsoft VC++, I don't see it documented on DMC++ or GCC, but in both cases it appears unlikely.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5482



--- Comment #2 from bearophile_hugs@eml.cc 2011-02-10 13:54:34 PST ---
(In reply to comment #1)
> Cannot reproduce.

You are right, to crash is the compiled program (with DMD 2.051 on Windows).


> The second case gives a runtime access violation, but neither example causes a compiler segfault.

As in the first case this time the compiled program gives: object.Error: Access Violation


> Is align(0) really valid? I don't think it makes sense.

I agree, I suggest to turn it into a compile-time error (as negative numbers
already do).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5482


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-03-01 17:13:23 PST ---
https://github.com/D-Programming-Language/dmd/commit/830011e21b22686932a65d1452965ae7589aadfc

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------