1950 – CTFE doesn't work correctly for structs passed by ref

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1950 - CTFE doesn't work correctly for structs passed by ref
Summary: CTFE doesn't work correctly for structs passed by ref
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
Reported: 2008年03月26日 16:52 UTC by Max Samukha
Modified: 2014年02月16日 15:22 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2008年03月26日 16:52:58 UTC
struct S
{
 int x;
}
int foo()
{
 S s;
 bar(s);
 return s.x;
}
void bar(ref S s)
{
 s.x = 10;
}
enum x = foo();
static assert(x == 10); // Fails, x is 0
Comment 1 Don 2009年08月17日 02:13:20 UTC
This bug also applies to D1.0, replacing the 'enum' with 
const int x = foo();
Comment 2 Don 2009年08月21日 00:20:15 UTC
I have fixed this in my copy of interpret.c, but it's rather more general. It allows arbitrary expressions as reference parameters. (Passing an array member by reference will result in wrong-code in DMD1.046).
Comment 3 Don 2009年08月25日 00:52:15 UTC
I have sent Walter my patch for this, it will be in the next release.
Comment 4 Walter Bright 2009年09月03日 13:23:39 UTC
Fixed dmd 1.047 and 2.032


AltStyle によって変換されたページ (->オリジナル) /