May 28, 2009 [Issue 3033] New: CTFE call of non-static member function allowed inside template | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3033 Summary: CTFE call of non-static member function allowed inside template Product: D Version: 1.045 Platform: PC OS/Version: Linux Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: kamm-removethis@incasoftware.de From http://www.dsource.org/projects/ldc/ticket/312 The code --- struct Struct { Struct method() { return *this; } } template Template() { const CONST_STRUCT = Struct().method(); // A: no error } alias Template!() foo; const CONST_STRUCT2 = Struct().method(); // B: error --- correctly produces an error for line B "non-constant expression (Struct()).method()" (the CTFE spec says: "4. the function may not be a non-static member, i.e. it may not have a this pointer"), but doesn't for line A. Please either make both lines work and update the spec, or make A an error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 17, 2009 [Issue 3033] CTFE call of non-static member function allowed inside template | ||||
---|---|---|---|---|
| ||||
Posted in reply to kamm-removethis@incasoftware.de | http://d.puremagic.com/issues/show_bug.cgi?id=3033 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |INVALID --- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-08-17 02:24:21 PDT --- This is invalid. The template never gets instantiated (certainly its value is never requested), so CTFE isn't involved. The alias is still OK, since it might be used at runtime. Try adding this line at the end: const CONST_STRUCT3 = foo.CONST_STRUCT; and then you'll correctly get an error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation