Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 20, 2014 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |contracts CC| |ibuclaw@gdcproject.org --- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> --- This is a closure-style bug. To fix, either: 1) Taking the address of 'a' should trigger VarDeclaration::checkNestedReference to add it to closureVars. void test(B this, size_t i, A a) { test.closure.a = a; test.closure.this = this; // body... test.out(test.closure); } void test.out(void *this) { // Takes address of &(this.a) ... } or 2) When calling in/out contracts, the parameters of the body function should be passed directly. void test(B this, size_t i, A a) { // body... test.out(this, i, a); } void test.out(void *this, size_t i, A a) { // Takes address of &a ... } -- |
August 20, 2014 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 --- Comment #2 from Tim <tim.dlang@t-online.de> --- The bug is not caused by taking the address of a. If the writeln calls are removed there is still a segmentation fault. -- |
August 20, 2014 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 --- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> --- (In reply to Tim from comment #2) > The bug is not caused by taking the address of a. If the writeln calls are > removed > there is still a segmentation fault. 'a' is dereferenced, so an address of it is still taken. -- |
August 20, 2014 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 --- Comment #4 from Tim <tim.dlang@t-online.de> --- (In reply to Tim from comment #0) > When compiled with LDC 0.14 there is no segmentation fault, but the addresses are still different and the value of a.x is wrong. That was wrong. It prints the correct value for a.x with LDC. -- |
August 20, 2014 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 --- Comment #5 from Tim <tim.dlang@t-online.de> --- (In reply to Iain Buclaw from comment #1) > 2) When calling in/out contracts, the parameters of the body function should be passed directly. > > void test(B this, size_t i, A a) > { > // body... > test.out(this, i, a); > } > > void test.out(void *this, size_t i, A a) > { > // Takes address of &a ... > } This would probably not work, if i is changed in the delegate: void test(size_t i, A a) out { writeln(i); } body { void delegate() dg = {i++;}; dg(); } -- |
July 01, 2015 [Issue 13339] Address of parameter wrong in out contract | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13339 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> --- *** This issue has been marked as a duplicate of issue 9383 *** -- |
Copyright © 1999-2021 by the D Language Foundation