digitalmars.D.bugs - [Issue 796] New: Error: AssertError Failure internal\invariant.d(14)
- d-bugmail puremagic.com (23/23) Jan 05 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (23/23) Jan 05 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (16/16) Jan 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (10/10) Jan 11 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (18/18) Jan 11 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (10/10) Apr 12 2007 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (12/12) Nov 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (14/14) Mar 07 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (8/17) Mar 07 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (13/13) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (14/14) Aug 30 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (11/12) Nov 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (11/11) Nov 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=796
- d-bugmail puremagic.com (12/12) Jan 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=796
http://d.puremagic.com/issues/show_bug.cgi?id=796 Summary: Error: AssertError Failure internal\invariant.d(14) Product: D Version: 1.00 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: lio lunesu.com The following code causes a run-time assertion failure in internal\invariant.d(14) when linked against a debug build of Phobos (-unittest -g -w): #class Class {} #void main(){ # Class c; # assert(c); #} It causes a run-time Access Violation when linked against the release build of Phobos. --
Jan 05 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 fvbommel wxs.nl changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec ------- Comment #1 from fvbommel wxs.nl 2007-01-05 08:48 ------- It seems to be according to the spec though. I just looked it up, and assert(object) checks object's invariant; not just that it isn't null (that's assert(object !is null) apparently). Not what I would've expected... This isn't exactly clearly noted: this is mentioned on http://www.digitalmars.com/d/class.html#invariants but not http://www.digitalmars.com/d/expression.html#AssertExpression where it would be expected (especially since you wouldn't normally look at the section on invariants when figuring out what an assert does). So maybe this should be noted there too (especially since every other use of objects in boolean context is a null check AFAIK). I've already added it to the comments page for that page. The invariant checking routine in the runtime does perform an assert(o !is null), but that only gets compiled into a non-release build of Phobos. In a release build it instead segfaults trying to look up the vtable of the object. (to get classinfo) --
Jan 05 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 ------- Comment #2 from lio lunesu.com 2007-01-06 02:54 ------- Nice catch! I never would have thought of that. In any case, the assertion failure / access violation can be easily fixed if the compiler where to add a null-pointer check prior to checking the invariants. Frankly, I think this makes sense too. We can expect many C/C++ people doing "assert(instance)" only to check the pointer. If it were to check both the pointer and the invariants, that would just make it even more useful. AFAIK, this cannot be changed by adding a check to invariant.d, since that would add unnecessary overhead to all invariant checks. The code generation for assert(instance) should be changed to include a pointer check: the assertion should fail for null-pointers: assert(classref) // => assert( (classref !is null) && _d_invariant(classref) ); --
Jan 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 fvbommel wxs.nl changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|spec |wrong-code ------- Comment #3 from fvbommel wxs.nl 2007-01-11 04:13 ------- It seems I misread the spec: it says the invariant *can* be checked on assert(classref), not that it *will* be. So the spec's fine. The bug seems to be in the compiler. --
Jan 11 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Keywords| |diagnostic Summary|Error: AssertError Failure |Asserting a null object |internal\invariant.d(14) |reference throws AssertError | |Failure | |internal\invariant.d(14) or | |Access Violation ------- Comment #4 from smjg iname.com 2007-01-11 09:04 ------- Indeed, assert(classref) should be translated inline to assert((classref !is null) && _d_invariant(classref)); so that the error location is preserved. --
Jan 11 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 ------- Comment #5 from torhu yahoo.com 2007-04-12 18:55 ------- I think the assert feature would be more intuitive if assert(obj) would only check for a null reference. That's what people expect it to do, and that's what they use it for most of the time. But doing both kinds of checks would be better than the current behavior. If you really wanted to check the invariant explicitly, the syntax could be 'obj.invariant', 'invariant(obj)' or similar. This could be useful in the class' own methods, where there's no need to check for a null reference anyway. --
Apr 12 2007
http://d.puremagic.com/issues/show_bug.cgi?id=796 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei metalanguage.com AssignedTo|nobody puremagic.com |bugzilla digitalmars.com --- Comment #6 from Andrei Alexandrescu <andrei metalanguage.com> 2010-11-26 14:13:26 PST --- Still present in 2.050. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=796 Bernard Helyer <blood.of.life gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |blood.of.life gmail.com --- Comment #7 from Bernard Helyer <blood.of.life gmail.com> 2011-03-07 03:12:41 PST --- Every time I write assert(object); A dagger pierces my heart and I remember I must write assert(object !is null); Could we get this fixed this decade some time? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 07 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 --- Comment #8 from Stewart Gordon <smjg iname.com> 2011-03-07 04:17:53 PST --- (In reply to comment #7)Every time I write assert(object); A dagger pierces my heart and I remember I must write assert(object !is null); Could we get this fixed this decade some time?Indeed. The intended behaviour (check that object is non-null AND satisfies its invariants) needs to be built into the compiler, not delegated to the RTL. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 07 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 Mike Shulman <viritrilbia+d gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |viritrilbia+d gmail.com --- Comment #9 from Mike Shulman <viritrilbia+d gmail.com> 2011-05-31 13:45:01 PDT --- FYI: As a new D programmer, I found the segfault produced by this sort of code very confusing, and spent almost an hour trying to figure out where the issue in my code was and why I wasn't just getting an AssertError. Only when I found this bug report did I have any idea what was going on. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|diagnostic |patch CC| |yebblies gmail.com Platform|x86 |All Version|1.00 |D1 & D2 OS/Version|Windows |All --- Comment #10 from yebblies <yebblies gmail.com> 2011-08-31 03:17:34 EST --- https://github.com/D-Programming-Language/dmd/pull/358 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 30 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 Alex Rønne Petersen <xtzgzorex gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xtzgzorex gmail.com --- Comment #11 from Alex Rønne Petersen <xtzgzorex gmail.com> 2011-11-08 15:04:55 PST --- (In reply to comment #10)https://github.com/D-Programming-Language/dmd/pull/358+1 to this pull req from me. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Jesse.K.Phillips+D gmail.co | |m --- Comment #12 from yebblies <yebblies gmail.com> 2011-11-09 12:37:10 EST --- *** Issue 6913 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=796 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED --- Comment #13 from Walter Bright <bugzilla digitalmars.com> 2012-01-11 13:30:00 PST --- https://github.com/D-Programming-Language/dmd/commit/7d942b84fd09f0a63105f6a92cd744f8b86e6021 https://github.com/D-Programming-Language/dmd/commit/1d80ce140da28518c161c5b96111d4d4f92e6027 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 11 2012