[Issue 5500] New: Appender.put causes an invariant violation in struct with overloaded opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 29 00:13:10 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5500

           Summary: Appender.put causes an invariant violation in struct
                    with overloaded opAssign
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dransic at free.fr


--- Comment #0 from Nicolas Sicard <dransic at free.fr> 2011-01-29 00:10:59 PST ---
The execution of this code throws an assertion error.

import std.array;

struct Foo {
    int a, b;

    Foo opAssign(Foo rhs) {
        a = rhs.a;
        b = rhs.b;
        return this;
    }

    invariant () {
        assert (a <= b);
    }
}

unittest {
    auto app = appender!(Foo[]);
    auto foo = Foo(1, 2);
    app.put(foo);
}


Stack trace:

core.exception.AssertError at test(13): Assertion failure
----------------
5   test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00009a61 onAssertError + 65
6   test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00012e82 _d_assertm + 30
7   test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00002593 void test.__assert(int)
+ 27
8   test.d.E6E9779DFA87AC0EBDE59516F9288677 0x000025ef void
test.Foo.__invariant() + 23
9   test.d.E6E9779DFA87AC0EBDE59516F9288677 0x000025ae test.Foo
test.Foo.opAssign(test.Foo) + 14
10  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00002bfd void
std.array.Appender!(test.Foo[]).Appender.put!(test.Foo).put(test.Foo) + 113
11  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x0000262b void test.__unittest1()
+ 55
12  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00002573 void test.__modtest() +
11
13  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x0000a121 extern (C) bool
core.runtime.runModuleUnitTests().int __foreachbody247(ref object.ModuleInfo*)
+ 45
14  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x0000560f int
object.ModuleInfo.opApply(scope int delegate(ref object.ModuleInfo*)) + 79
15  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x0000a012 runModuleUnitTests + 134
16  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00013202 extern (C) int
rt.dmain2.main(int, char**).void runAll() + 38
17  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x00013156 extern (C) int
rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 38
18  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x000130e7 main + 179
19  test.d.E6E9779DFA87AC0EBDE59516F9288677 0x0000255d start + 53

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


More information about the Digitalmars-d-bugs mailing list