Bug 14779 – incorrect addressing of arguments in require/in-contract

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-07T08:39:00Z
Last change time
2017-07-22T12:36:03Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2015-07-07T08:39:06Z
cat > bug.d << CODE class Foo { final @property void value(int val) in { assert(val == 0); } body { } } void main() { auto foo = new Foo(); foo.value = 0; } CODE dmd -run bug ---- [email protected](6): Assertion failure ---- Seems like the addressing the require function (in contract) is wrong. This only affects master, not 2.068.0-b1. Old ASM: mov qword ptr [rbp-10H], rdi ; 0008 _ 48: 89. 7D, F0 mov dword ptr [rbp-8H], esi ; 000C _ 89. 75, F8 lea rdi, [rbp-10H] ; 000F _ 48: 8D. 7D, F0 call _D3bug3Foo5valueMFNdiZ9__requireMFZv ; 0013 _ E8, 00000000(rel) _D3bug3Foo5valueMFNdiZ9__requireMFZv PROC push rbp ; 0000 _ 55 mov rbp, rsp ; 0001 _ 48: 8B. EC sub rsp, 16 ; 0004 _ 48: 83. EC, 10 cmp dword ptr [rdi+8H], 0 ; 0008 _ 83. 7F, 08, 00 New ASM: mov qword ptr [rbp-10H], rdi ; 0008 _ 48: 89. 7D, F0 mov dword ptr [rbp-8H], esi ; 000C _ 89. 75, F8 call _D3bug3Foo5valueMFNdiZ9__requireMFZv ; 000F _ E8, 00000000(rel) _D3bug3Foo5valueMFNdiZ9__requireMFZv PROC push rbp ; 0000 _ 55 mov rbp, rsp ; 0001 _ 48: 8B. EC sub rsp, 16 ; 0004 _ 48: 83. EC, 10 mov qword ptr [rbp-8H], rdi ; 0008 _ 48: 89. 7D, F8 cmp dword ptr [rbp], 0 ; 000C _ 83. 7D, 00, 00
Comment #1 by k.hara.pg — 2015-07-07T09:09:52Z
Introduced in: https://github.com/D-Programming-Language/dmd/pull/4788 And, I found a long-standing wrong-code issue with out-contract, which the root issue would be same with. class Foo { final @property void value(int val) //in { assert(val == 0); } out { assert(val == 0); } // assertion fails body { } } void main() { auto foo = new Foo(); foo.value = 0; }
Comment #2 by k.hara.pg — 2015-07-07T10:49:38Z
Comment #3 by github-bugzilla — 2015-07-08T09:10:53Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9e6bc30b0997867d21b794b933cbf822e7d8cfa6 fix Issue 14779 - incorrect addressing of arguments in require/in-contract https://github.com/D-Programming-Language/dmd/commit/971b319e45c4e81825265fdb04363806a76bd4a0 Merge pull request #4803 from 9rnsr/fix14779 [REG] Issue 14779 - incorrect addressing of arguments in require/in-contract
Comment #4 by k.hara.pg — 2015-11-02T02:04:59Z
*** Issue 15266 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2017-07-22T12:36:03Z
Commits pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9e6bc30b0997867d21b794b933cbf822e7d8cfa6 fix Issue 14779 - incorrect addressing of arguments in require/in-contract https://github.com/dlang/dmd/commit/971b319e45c4e81825265fdb04363806a76bd4a0 Merge pull request #4803 from 9rnsr/fix14779