D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9647 - Ignored immutable in struct literal
Summary: Ignored immutable in struct literal
Status: RESOLVED DUPLICATE of issue 6578
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-03-04 17:23 UTC by bearophile_hugs
Modified: 2013-03-05 07:25 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-03-04 17:23:22 UTC
Issue found by Ali Çehreli:
http://forum.dlang.org/thread/kh3dkf$22eb$1@digitalmars.com

DMD 2.063alpha accepts this code, ignoring the immutable():


struct Foo {
    int[] arr;
    this(int[] arr_) {
        this.arr = arr_;
    }
}
void main() {
    auto arr = [1];
    auto f = immutable(Foo)(arr);
    pragma(msg, typeof(f)); // Prints: Foo
    f.arr[0]++;
}
Comment 1 Ali Cehreli 2013-03-04 17:45:39 UTC
Thanks bearophile...

Note that the bug disappears when the constructor is removed.
Comment 2 yebblies 2013-03-05 07:25:02 UTC

*** This issue has been marked as a duplicate of issue 6578 ***