Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

fix Issue 17876 - [REG 2.074] Internal error when comparing inout(Foo[][]) with Foo[][]#1934

Merged
MartinNowak merged 2 commits intodlang:stablefrom
rainers:issue_17876
Oct 9, 2017
Merged

fix Issue 17876 - [REG 2.074] Internal error when comparing inout(Foo[][]) with Foo[][]#1934
MartinNowak merged 2 commits intodlang:stablefrom
rainers:issue_17876

Conversation

@rainers
Copy link
Member

@rainers rainers commented Oct 8, 2017

moved bad assertion that failed for arrays of arrays with mixed modifiers to the memcmp version which should work on values anyway.

Also fixed bad comparison via memcmp only comparing first element.

…s with mixed modifiers to the memcmp version which should work on values anyway.

Also fixed bad comparison via memcmp only comparing first element.
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @rainers!

Bugzilla references

Auto-close Bugzilla Description
17876 [REG 2.074] Internal error when comparing inout(Foo[][]) with Foo[][]

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Oct 8, 2017
@schveiguy
Copy link
Member

Checking that both are the same type was implied in the template constraint, because only T1 is checked for 'isScalar'.

To have the same behavior, I think you need to check if both are not scalar. Otherwise:

struct S
{
   int x;
   int opCmp(int y) { return x < y ? -1 : x > y; }
}

auto s = [S(1)];
auto i = [0];
assert(s[0] > i[0]); // works
assert(i[0] < s[0]); // works
assert(s > i); // works
assert(i < s); // error

There is an opportunity here, because really s and i should be comparable. But maybe that's good to leave for an enhancement.

@rainers
Copy link
Member Author

rainers commented Oct 9, 2017

To have the same behavior, I think you need to check if both are not scalar.

The constraint so far did not check the second argument, so it would run into the internal error later on (D does not have SFINAE). I've added it nevertheless.

@MartinNowak MartinNowak merged commit ec9a79e into dlang:stable Oct 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Fix Include reference to corresponding bugzilla issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants