Bug 1363 – Compile-time issue with structs in 'for'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-07-23T02:48:00Z
Last change time
2014-02-16T15:23:51Z
Assigned to
bugzilla
Creator
samukha
Comments
Comment #0 by samukha — 2007-07-23T02:48:44Z
Related to 1300.
struct Bar
{
int x;
}
int foo()
{
Bar bar;
// Error: cannot evaluate foo() at compile time
for (bar.x = 0; bar.x < 10; bar.x++)
{
}
return bar.x;
}
void main(char[][] args)
{
static x = foo();
}
Comment #1 by samukha — 2007-07-23T03:39:47Z
This one gives
'Error: cannot cast int to char[]':
struct Bar
{
int x;
char[] s;
}
char[] foo()
{
Bar bar; // Works if bar is explicitly initialized.
return bar.s;
}
void main(char[][] args)
{
static x = foo();
}