Bug 12827 – [ICE] Segfault on immutable field self-initialization

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-31T17:32:00Z
Last change time
2014-09-11T19:01:18Z
Keywords
ice
Assigned to
nobody
Creator
camille.brugel

Comments

Comment #0 by camille.brugel — 2014-05-31T17:32:58Z
DMD segfaults if the member variable has the same name as the template argument Example of code : struct Foo(int i) { immutable int i = i; } void main() { Foo!5 foo; writeln(foo); } Output : app.d(20): Deprecation: variable app.Foo!5.Foo.i immutable field with initializer should be static, __gshared, or an enum Segmentation fault (core dumped)
Comment #1 by camille.brugel — 2014-05-31T17:40:52Z
In fact it does'nt have to be template you affect an immutable member with himself and it segfaults : struct Test { immutable int i = i; } void main() {}
Comment #2 by github-bugzilla — 2014-09-03T21:15:01Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/da3a468db8469192f22851f1887f7bb5d4f3b5ea Fix Issue 12827 - [ICE] Segfault on immutable field self-initialization https://github.com/D-Programming-Language/dmd/commit/2117931e57c2319d23dde442e12596141116f0b9 Merge pull request #3871 from maxfom/fix12827 Fix Issue 12827 - [ICE] Segfault on immutable field self-initialization
Comment #3 by hsteoh — 2014-09-11T19:01:18Z
On git HEAD, the first code example now gives a compile error: ------- test.d(4): Deprecation: variable test.Foo!5.Foo.i immutable field with initializer should be static, __gshared, or an enum test.d(4): Error: circular initialization of i test.d(9): Error: template instance test.Foo!5 error instantiating ------- The second example also: ------- test.d(3): Deprecation: variable test.Test.i immutable field with initializer should be static, __gshared, or an enum test.d(3): Error: circular initialization of i ------- Seems the PR has fixed this bug.