Bug 2099 – Text and Sample Code Disagree (non-static local invariant declaration)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-05-12T04:44:00Z
Last change time
2015-06-09T01:31:15Z
Assigned to
bugzilla
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2008-05-12T04:44:58Z
On the page (http://www.digitalmars.com/d/2.0/const3.html), in the section "Invariant Storage Class", the text and sample code disagree on when non-static local invariant declarations are evaluated (compile-time or run-time).
The text says (asterisk emphasis added):
"The initializer for a non-static local invariant declaration is evaluated at ***compile time***:"
But the sample code immediately following says (asterisk emphasis added):
int foo(int f)
{
invariant x = f + 1; // evaluated at ***run time***
x = 3; // error, x is invariant
}