Bug 1319 – compiler crashes with functions that take const ref arguments
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-07-05T18:47:00Z
Last change time
2015-06-09T01:04:59Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2007-07-05T18:47:45Z
struct MyStruct
{
// the presence/absence of fields is irrelevant
}
void test(const ref MyStruct scheme)
{
}
void main()
{
MyStruct scheme;
test(scheme);
}
Comment #1 by regan — 2007-07-26T07:33:59Z
Same bug I think:
void main() { int delegate(const ref int) dg; const int i; dg(i); }
Found it trying to make opApply work with a const class reference.
Comment #2 by kamm-removethis — 2007-07-26T08:17:59Z
*** Bug 1374 has been marked as a duplicate of this bug. ***
Comment #3 by kamm-removethis — 2007-07-31T01:53:50Z
*** Bug 1387 has been marked as a duplicate of this bug. ***
Comment #4 by wbaxter — 2007-10-13T15:00:57Z
*** Bug 1576 has been marked as a duplicate of this bug. ***
Comment #5 by ddparnell — 2007-10-29T00:31:45Z
I just tripped over this one today too. Here is my minimum test case...
void Foo(const ref int A) {}
void main()
{
Foo(1);
}
And using 'invariant' instead of 'const' also crashes the compiler.
Comment #6 by spam — 2007-11-29T06:31:57Z
i am raising this one, cause it is really critical for me, i use a couple of really huge structs and i pass them by ref to methods but i want to protect them from being mutated which i want to use the const for. this is one big reason i am using the D2.0 branch in the first place. I have a rather big team of coders working on the project, i want to protect certain stuff from getting messed up by someone. please fix this.
Comment #7 by wbaxter — 2007-11-29T17:30:45Z
Agreed. This is a big deal. My code has lots of structs being passed around by ref for efficiency that really should be "const ref". The fact that it's been reported 4 times by different people should also be a big clue. Here's hoping for a fix in 2.009. I don't see myself moving over to D2.x until this one is fixed because I've got too much code that should be "const ref" that I'll just have to go back over again when const ref finally works.