3401 – Segfault(expression.c) on invariant + method overload

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3401 - Segfault(expression.c) on invariant + method overload
Summary: Segfault(expression.c) on invariant + method overload
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
: 3405 (view as issue list)
Depends on:
Blocks:
Reported: 2009年10月14日 08:55 UTC by Moritz Warning
Modified: 2014年04月18日 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Moritz Warning 2009年10月14日 08:55:43 UTC
dmd 1.049 and svn r102 crash on this code.
class A
{
 invariant
 {
 // assert (true);
 }
	
 void fill ()
 {
 }
}
class B : A
{
	void fill ()
 {
 }
}
Program received signal SIGSEGV, Segmentation fault.
VarExp (this=0x96f20c0, loc={filename = 0x96daa88 "tango.io.Buffer.d", linnum = 20}, var=0x0) at expression.c:3914
3914	 this->type = var->type;
Current language: auto; currently c++
(gdb) bt
#0 VarExp (this=0x96f20c0, loc={filename = 0x96daa88 "tango.io.Buffer.d", linnum = 20}, var=0x0) at expression.c:3914
#1 0x080c3765 in FuncDeclaration::mergeFensure (this=0x96db4b0, sf=0x0) at func.c:1575
#2 0x080c4089 in FuncDeclaration::semantic3 (this=0x96db4b0, sc=0x96f14f8) at func.c:742
#3 0x0811948d in AggregateDeclaration::semantic3 (this=0x96db2e8, sc=0x96f14f8) at struct.c:88
#4 0x080eac3d in Module::semantic3 (this=0x96da980) at module.c:804
#5 0x080e8cf3 in main (argc=Cannot access memory at address 0x0
) at mars.c:1115
Comment 1 Moritz Warning 2009年10月14日 08:56:46 UTC
The backtrace is for dmd svn r102.
This ticket may also need a better title.
Comment 2 Don 2009年10月15日 01:57:40 UTC
Crashing in VarExp::VarExp(). 
var is NULL.
Comment 3 Don 2009年10月15日 02:07:03 UTC
func.c, line 1568 (DMD 1.050), in mergeFensure(): Need to check fdensure as 
well as fensure.
	FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i];
	sf = fdv->mergeFensure(sf);
-	if (fdv->fensure)
+	if (fdv->fensure && fdv->fdensure)
	{
	 //printf("fdv->fensure: %s\n", fdv->fensure->toChars());
	 // Make the call: __ensure(result)
	 Expression *eresult = NULL;
Likewise in mergeFrequire, line 1524 should probably be:
	FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i];
	sf = fdv->mergeFrequire(sf);
-	if (fdv->frequire)
+	if (fdv->frequire && fdv->fdrequire)
	{
	 //printf("fdv->frequire: %s\n", fdv->frequire->toChars());
	 /* Make the call:
	 * try { __require(); }
	 * catch { frequire; }
	 */
	 Expression *eresult = NULL;
	 Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdrequire), eresult);
	 Statement *s2 = new ExpStatement(loc, e);
Comment 4 Moritz Warning 2009年10月15日 13:02:23 UTC
The test case compiles and runs with dmd svn r215.
Comment 5 Moritz Warning 2009年10月15日 14:03:32 UTC
*** Issue 3405 has been marked as a duplicate of this issue. ***
Comment 6 Walter Bright 2009年11月06日 11:30:59 UTC
Fixed dmd 1.051 and 2.036


AltStyle によって変換されたページ (->オリジナル) /