[Issue 11428] A simple std.array.array call at compile-time refused
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 3 06:30:21 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11428
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #1 from monarchdodra at gmail.com 2013-11-03 06:30:19 PST ---
It's not a regression, because array was not CTFE-able prior to 2.064. I say
CTFE, because you are declaring a global static. This also recreates the issue:
//----
import std.array: array;
void main()
{
enum r1 = [""].array; // KO
static const r2 = [""].array; // KO
}
//----
The "issue" seems to only happen if the element type is a string. I can't
reproduce with other types. Further more, it only happens if the string is a
literal. EG:
//----
void main()
{
static const string r = "";
static const r1 = r.array; // OK
static const r2 = [1].array; // OK
static const r2 = [""].array; // ERROR
}
//----
Here is a reduced case.
//----
T[] arr(T)(T[] input)
{
static T* getAddr(ref T t)
{
return &t; //Error: returning a pointer to a local stack variable
}
getAddr(input[0]);
return input;
}
void main()
{
static const string r = "";
static const r1 = r.arr; // OK
static const r2 = [1].arr; // OK
static const r3 = [""].arr; // ERROR
}
//----
I can't really make any sense of this on my end. Maybe Don has an idea?
--
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