[Issue 4891] New: Assignment from non-pure function to pure function pointer compiles when it shouldn't
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 18 16:08:08 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4891
Summary: Assignment from non-pure function to pure function
pointer compiles when it shouldn't
Product: D
Version: unspecified
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2010-09-18 16:07:33 PDT ---
Take this program
struct S
{
public:
this(int function(int) pure func)
{
_func = func;
}
@property int function(int) pure func()
{
return func;
}
private:
int function(int) pure _func;
}
int add1(int num)
{
return num + 1;
}
void main()
{
auto s = S(&add1);
}
The construction of s should not compile because add1() is not a pure function.
Granted, it could be pure if I declared it as such, but I didn't. And the
compiler isn't figuring out that add1() could be pure and letting it through
because of that because if I add a writeln() call to add1(), it still compiles.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list