D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16115 - [REG2.067] Wrong code with comma operator
Summary: [REG2.067] Wrong code with comma operator
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2016-06-02 15:04 UTC by Vladimir Panteleev
Modified: 2016-10-01 11:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2016-06-02 15:04:08 UTC
///////////////// test.d ////////////////
int n;

auto call()
{
//  n = Test.tag;              // Works
    return n = Test.tag, null; // Crash
}

struct Test
{
    enum tag = 42;
}

void main()
{
    call();

    assert(n == 42);
}
/////////////////////////////////////////

Introduced in https://github.com/dlang/dmd/pull/3979
Comment 1 Walter Bright 2016-07-27 07:46:22 UTC
Clearer test case:

int n;

auto call()
{
    version (none) // works
    {
	n = Test.tag;
	return null;
    }
    else // assert error
    {
	return n = Test.tag, null;
    }
}

struct Test
{
    enum tag = 42;
}

void main()
{
    call();

    assert(n == 42);
}
Comment 2 Walter Bright 2016-08-13 01:41:09 UTC
https://github.com/dlang/dmd/pull/6054
Comment 3 github-bugzilla 2016-08-13 14:11:54 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/f9fd81983118d94a6f3da915e781c72b54a67247
fix Issue 16115 - [REG2.067] Wrong code with comma operator

https://github.com/dlang/dmd/commit/113e5f77d335dc3483127b13073690981b6a61b6
Merge pull request #6054 from WalterBright/fix16115

fix Issue 16115 - [REG2.067] Wrong code with comma operator
Comment 4 github-bugzilla 2016-10-01 11:48:26 UTC
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/f9fd81983118d94a6f3da915e781c72b54a67247
fix Issue 16115 - [REG2.067] Wrong code with comma operator

https://github.com/dlang/dmd/commit/113e5f77d335dc3483127b13073690981b6a61b6
Merge pull request #6054 from WalterBright/fix16115