Bug 1286 – crash on invariant struct member function referencing globals
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-06-23T09:53:00Z
Last change time
2014-02-14T20:35:42Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
lutger.blijdestijn
Comments
Comment #0 by lutger.blijdestijn — 2007-06-23T09:53:18Z
When an invariant member function of an invariant struct uses global or static member variables, the compiler crashes. This happens only when this function is invoked more than once. See the code below.
int bar;
struct Foo
{
invariant int func()
{
return bar;
}
}
void main()
{
invariant(Foo) foo;
printf("%d", foo.func());
/* uncomment this line and the compiler aborts with:
Assertion failure: 'ito->isInvariant()' on line 335 in file 'mtype.c'
*/
//printf("%d", foo.func());
}