Bug 8818 – CTFE fails to compare strings correctly

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-14T06:16:00Z
Last change time
2015-06-09T05:11:39Z
Keywords
CTFE, patch
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2012-10-14T06:16:27Z
Compiling with current version from github: bool test() { string op1 = "aa"; string op2 = "b"; assert("b" >= "aa"); assert(op2 >= op1); return true; } pragma(msg,test()); void main() { } produces: test.d(7): Error: assert(op2 >= op1) failed test.d(11): called from here: test() test() This does not happen with dmd 2.060. The regression was probably introduced with this commit: SHA-1: f3ee71f1f422fd0ee8863109469f4065a8305b5f * Merge pull request #1114 from donc/ctfe8644_arrayliteralcmp Fix bug 8644 - CTFE doesn't support string <,> on array literals and is caused by ctfeRawCmp in interpret.c changing the semantics of the comparison, because it compares the length of arrays before looking at the contents.
Comment #1 by r.sagitario — 2012-10-17T00:37:57Z
Comment #2 by github-bugzilla — 2012-10-20T15:14:05Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/81dfc8e45c6576c3711c77963da4744dad382cd6 fix issue 8818: CTFE fails to compare strings correctly https://github.com/D-Programming-Language/dmd/commit/fb6808ec01e95755aef5e68dbd9d99a5eaefa97b Merge pull request #1190 from rainers/issue8818 fix issue 8818: CTFE fails to compare strings correctly