www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7194] New: [CTFE] Incorrect behaviour with pointers as local struct variable fields

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7194

           Summary: [CTFE] Incorrect behaviour with pointers as local
                    struct variable fields
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis <verylonglogin.reg gmail.com> 2012-01-01 14:15:04 MSK
---
---
struct S { int* p, p2; }

int f() {
    assert(S().p == null);   // passes
    assert(!S().p);          // passes
    assert(S().p == S().p2); // passes

    auto s = S();
    assert(!s.p); // passes, note: `s.p` also passes
    assert(s.p == null); // fails
    assert(s.p == s.p2); // fails
    return 0;
}

int g() {
    auto s = S();
    assert(s.p);  // passes but should fail
    return 0;
}

void t()() { enum e = g(); } // const for D1

static assert(f() == 0);
// static assert is in a function because of    BUG3448    aka    BUG965   
void f3448() { static assert(!__traits(compiles, t!()())); } // is(typeof())
for D1
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 01 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7194


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2012-01-04
18:25:27 PST ---
https://github.com/D-Programming-Language/dmd/commit/51bc588d2e834650e5278247cd06b5da36569feb

https://github.com/D-Programming-Language/dmd/pull/602

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