Summary: Ignored const with struct with constructor
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, diagnostic
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2011-08-30 04:57:48 PDT ---
In DMD 2.055head this compiles and runs with no errors:

struct Foo {
    int x;
    this(int x_) { this.x = x_; }
void main() {
    auto f1 = new const(Foo)(1);
    auto f2 = new immutable(Foo)(1);
    auto f3 = const(Foo)(1);
    auto f4 = immutable(Foo)(1);

While this generates two errors:

struct Foo {
    int x;
void main() {
    auto f5 = const(Foo)(1);
    f5.x++; // error
    auto f6 = immutable(Foo)(1);
    f6.x++; // error

I think in the first program the f1,f2,f3,f4 structs too need to raise a
compile-time error.

Thanks to Timon Gehr for a suggestion.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to