March 06, 2017 [Issue 17244] New: Undefined comparison of struct arrays is allowed | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17244 Issue ID: 17244 Summary: Undefined comparison of struct arrays is allowed Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: thecybershadow@gmail.com Comparison of structs without an opCmp is undefined: struct A { int i; } static assert(!__traits(compiles, A(1) < A(2) )); // OK However, comparing arrays of such structs is allowed: static assert(!__traits(compiles, [A(1)] < [A(2)])); // Fails Andrei wrote[1]: > Oh. Yah, that's problematic too - you can't order lexicographically unless elements are ordered. [1]: https://github.com/dlang/druntime/pull/1787#discussion_r104548229 -- |
Copyright © 1999-2021 by the D Language Foundation