4448 – labeled break doesn't work in CTFE

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4448 - labeled break doesn't work in CTFE
Summary: labeled break doesn't work in CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2010年07月11日 15:12 UTC by BCS
Modified: 2011年06月23日 00:31 UTC (History)
1 user (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 BCS 2010年07月11日 15:12:45 UTC
string CTFE(string s) {
 int i, j;
 L1: for(i = 0; i < s.length; i++)
 switch(s[i]) {
 case ' ', '\n', '\r', '\t':
 continue;
 default: break L1;
 }
 L2: for(j = s.length; j > i; j--)
 switch(s[j-1]) {
 case ' ', '\n', '\r', '\t':
 continue;
 default: break L2;
 }
 return s[i..j];
}
import std.stdio;
pragma(msg, CTFE(" hello world!\n"));
void main(){ writef("'%s'\n", CTFE(" hello world!\n")); }
the function works at runtime but fails under CTFE. There may be a few cases where labeled break may be hard to deal with but this one shouldn't cause problems.


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