[Issue 13339] New: Address of parameter wrong in out contract
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Aug 20 04:15:20 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13339
Issue ID: 13339
Summary: Address of parameter wrong in out contract
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: tim.dlang at t-online.de
The following code results in a segmentation fault at runtime when compiled
with DMD 2.066 on Arch Linux x86_64:
import std.stdio;
class A
{
int x;
}
class B
{
void test(size_t i, A a)
out
{
writeln("after: ", &a);
auto x = a.x; // Segmentation fault
writeln(a.x);
}
body
{
void delegate() dg = {size_t s = i;};
writeln("before: ", &a);
}
}
void main()
{
B b = new B;
b.test(1234, new A);
}
The output shows, that the address of a is different in body and out constract:
before: 7FFFC53B81A0
after: 7FA64F4BBFE8
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.
With GDC 4.9.1 the code does not compile with the following error message:
ebnftests.d: In member function '__ensure':
ebnftests.d:12: internal compiler error: in expand_expr_real_1, at expr.c:9454
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
--
More information about the Digitalmars-d-bugs
mailing list