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



--- Comment #3 from Leandro Lucarella <llu...@gmail.com> 2010-10-16 16:06:59 
PDT ---
(In reply to comment #2)
> It's undocumented, but struct invariants are fired on pointers:
> --------------------
> struct S
> {
>     invariant() { assert(0); }  // (3)
> }
> void main()
> {
>     S s;
>     assert(&s);
> }
> --------------------
> % dmd -run test.d
> core.exception.asserter...@test(3): Assertion failure
> --------------------
> 
> Though it's non-intuitive, I find it reasonable considering that structs can
> define opCast to bool.  assert(s) would be ambiguous if s had both invariant
> and opCast!bool.

I never expected that, but it makes sense as you mention.

I guess this behavior should be documented in the specs.

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

Reply via email to