[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2023-01-13 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #21 from Bolpat  ---
Maybe this can be done via a caller-side lowering:

The expression `T(args...)` would become
```d
{
auto result = T(args...);
assert(() @trusted { return  }());
return result;
}()
```

The @trusted block is to be able to take the address without dip1000.

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2023-01-13 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

Bolpat  changed:

   What|Removed |Added

 CC||qs.il.paperi...@gmail.com

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2019-06-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #20 from Dlang Bot  ---
@RazvanN7 created dlang/dmd pull request #10022 "Fix Issue 519 - Invariant not
called from autogenerated class/struct constructor/destructor" fixing this
issue:

- Fix Issue 519 - Invariant not called from autogenerated class/struct
constructor/destructor

https://github.com/dlang/dmd/pull/10022

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2018-02-08 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #19 from Walter Bright  ---
Rebooted as: https://github.com/dlang/dmd/pull/7536/

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|D1  D2 |D2

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2015-01-15 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #18 from Andrei Alexandrescu and...@erdani.com ---
(In reply to Martin Nowak from comment #17)
 (In reply to Andrei Alexandrescu from comment #16)
  I stated this elsewhere, just making sure I don't forget: probably we don't
  want to invoke invariants during the GC cycle.
 
 Walter has a different opinion on this, I don't follow his argument though.
 http://forum.dlang.org/post/m753hk$pt2$1...@digitalmars.com
 
 Currently it can't be done, because the calls to the invariant are embedded
 into the generated destructor function.

Well a simple invariant would be:

assert(this.parent.child is this);

which would be placed in some child node, or could be moved in parent like
this:

assert(this.child.parent is this);

The invariant involves two objects no matter where you put it.

 Also the invariant is called twice, before and after running the destructor.
 The latter forces one to perform additional cleanup, e.g. setting pointers
 to null.

That's definitely a problem. Invariants are not supposed to hold after
destruction.

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2015-01-15 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #17 from Martin Nowak c...@dawg.eu ---
(In reply to Andrei Alexandrescu from comment #16)
 I stated this elsewhere, just making sure I don't forget: probably we don't
 want to invoke invariants during the GC cycle.

Walter has a different opinion on this, I don't follow his argument though.
http://forum.dlang.org/post/m753hk$pt2$1...@digitalmars.com

Currently it can't be done, because the calls to the invariant are embedded
into the generated destructor function.

Also the invariant is called twice, before and after running the destructor.
The latter forces one to perform additional cleanup, e.g. setting pointers to
null.

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #15 from Stewart Gordon s...@iname.com ---
(In reply to Walter Bright from comment #11)
 I'm skeptical, however, of the value of running it on default construction,
 as those values will always be the .init ones.

Maybe have a rule that, if the -unittest option is set, autogenerate a unittest
to call the invariant on the .init.

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

Andrej Mitrovic andrej.mitrov...@gmail.com changed:

   What|Removed |Added

 CC|andrej.mitrov...@gmail.com  |

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

 CC||c...@dawg.eu

--- Comment #14 from Martin Nowak c...@dawg.eu ---
Rainer raised an important question for running invariant before class
destruction. Because GC finalization order is undetermined an invariant that
would check whether some classes's field points to a valid instance could fail
because the pointed-to class could already have been finalized.


http://forum.dlang.org/post/m4eu6v$trq$1...@digitalmars.com

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #11 from Walter Bright bugzi...@digitalmars.com ---
I agree that the invariant should run on non-empty struct literals and on
destruction.

I'm skeptical, however, of the value of running it on default construction, as
those values will always be the .init ones.

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #12 from Walter Bright bugzi...@digitalmars.com ---
https://github.com/D-Programming-Language/dmd/pull/4136

(But does not do invariant call for default construction, will change spec to
say that isn't don't.)

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2014-11-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=519

--- Comment #13 from Walter Bright bugzi...@digitalmars.com ---
Documentation fix:

https://github.com/D-Programming-Language/dlang.org/pull/699

--


[Issue 519] Invariant not called from autogenerated class/struct constructor/destructor

2012-10-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=519


Denis Shelomovskij verylonglogin@gmail.com changed:

   What|Removed |Added

 CC||verylonglogin@gmail.com
Summary|Invariant not called from   |Invariant not called from
   |autogenerated constructor   |autogenerated class/struct
   ||constructor/destructor


--- Comment #8 from Denis Shelomovskij verylonglogin@gmail.com 2012-10-30 
16:05:58 MSK ---
Structs have the same problem:
---
import std.stdio;

struct S
{
invariant() { writeln(invariant); } // never called
// ~this() { writeln(~this); } // uncomment to call invariant
}

void main()
{
auto s = S();
}
---

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