Bug 5482 – Crash with align(0)

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-01-25T02:59:00Z
Last change time
2011-03-01T17:13:23Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-01-25T02:59:10Z
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(); }
Comment #1 by clugdbug — 2011-02-10T12:54:55Z
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.
Comment #2 by bearophile_hugs — 2011-02-10T13:54:34Z
(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).
Comment #3 by clugdbug — 2011-03-01T17:13:23Z