2634 – Function literals are non-constant.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2634 - Function literals are non-constant.
Summary: Function literals are non-constant.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
: 5143 (view as issue list)
Depends on:
Blocks:
Reported: 2009年01月29日 12:35 UTC by Burton Radons
Modified: 2014年04月18日 09:12 UTC (History)
5 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 Burton Radons 2009年01月29日 12:35:46 UTC
This code fails compilation:
 void test () { }
 // Compiles okay.
 auto a = &test;
 // Error: non-constant expression __funcliteral1
 auto b = function void () { }; 
As far as I can tell there is no reason for function literals to be non-constant if they're not synthesized during runtime.
Comment 1 bearophile_hugs 2010年10月31日 13:47:12 UTC
*** Issue 5143 has been marked as a duplicate of this issue. ***
Comment 2 Taylor Everding 2011年03月11日 14:35:35 UTC
It may be useful to know that 
void main() {
 auto a = function void() {};
}
compiles correctly, but when a is moved outside main the Error occurs.


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