Bug 14430 – [REG2.060] Null parameter is detected as non-null.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-04-09T15:10:00Z
Last change time
2017-07-22T12:35:39Z
Keywords
wrong-code
Assigned to
nobody
Creator
14crgg+ekargo2d7qijk

Attachments

IDFilenameSummaryContent-TypeSize
1511test.dTest code that generates the problem.application/x-dsrc490

Comments

Comment #0 by 14crgg+ekargo2d7qijk — 2015-04-09T15:10:38Z
What: I defined a class with a single method in it. Method has 6 parameters. Other than first parameter, all others has default value. 3rd, 4th, and 5th parameters are string and their default value is "null". I create an instance of that class, and call that method 2 times with only first parameter. Expected: Parameters those have "null" value by default should be "null" always. Result: In the first call, it works correctly. In the second and later calls, assert doesn't pass, and it says those parameters are not null. Test: Tested on both "DMD64 D Compiler v2.066 and v2.070 on Archlinux" and "DMD64 D Compiler v2.070 on Ubuntu 14.04". Results are same. rdmd test.d One person reported it works correctly on LDC and rdmd test.d on Archlinux. But says that with "dmd -O", and "dmd -release", it works wrong as well. This problem can be generated repeatedly.
Comment #1 by 14crgg+ekargo2d7qijk — 2015-04-09T15:11:26Z
Created attachment 1511 Test code that generates the problem.
Comment #2 by ag0aep6g — 2015-04-09T18:27:32Z
Reduced: ---- void setCookie(long x = 1L << 32L, string y = null){ assert(b.ptr is null); } void main(){ setCookie(); } ---- Fails when x's default value has all zero lower 32 bits, but not all zero higher 32 bits. y.ptr then has the value of x. Works correctly with v2.059. Fails since v2.060.
Comment #3 by ag0aep6g — 2015-04-09T18:29:25Z
(In reply to ag0aep6g from comment #2) > void setCookie(long x = 1L << 32L, string y = null){ > assert(b.ptr is null); Woops, b.ptr should be y.ptr of course. Full proper test case: ---- void setCookie(long x = 1L << 32L, string y = null){ assert(y.ptr is null); } void main(){ setCookie(); } ----
Comment #4 by devw0rp — 2015-04-09T23:01:59Z
I just ran the example in 2.067 myself, and I can see it happening. It doesn't seem to happen if some of the arguments are taken away, and it might be specific to slices. It looks like the pointer for the slice is being set to some high value somehow, and the length is being set to 0.
Comment #5 by kozzi11 — 2015-04-10T12:06:33Z
(In reply to w0rp from comment #4) > I just ran the example in 2.067 myself, and I can see it happening. It > doesn't seem to happen if some of the arguments are taken away, and it might > be specific to slices. It looks like the pointer for the slice is being set > to some high value somehow, and the length is being set to 0. how do you compile the example (which command rdmd, use dub, dmd, ldc ...)?
Comment #6 by kozzi11 — 2015-04-10T12:16:47Z
With DMD v2.063 same issue, ldc works ok.
Comment #7 by devw0rp — 2015-04-10T17:46:39Z
(In reply to Daniel Kozak from comment #5) > (In reply to w0rp from comment #4) > > I just ran the example in 2.067 myself, and I can see it happening. It > > doesn't seem to happen if some of the arguments are taken away, and it might > > be specific to slices. It looks like the pointer for the slice is being set > > to some high value somehow, and the length is being set to 0. > > how do you compile the example (which command rdmd, use dub, dmd, ldc ...)? I used rdmd myself.
Comment #8 by kozzi11 — 2015-04-10T19:22:30Z
(In reply to w0rp from comment #7) > (In reply to Daniel Kozak from comment #5) > > (In reply to w0rp from comment #4) > > > I just ran the example in 2.067 myself, and I can see it happening. It > > > doesn't seem to happen if some of the arguments are taken away, and it might > > > be specific to slices. It looks like the pointer for the slice is being set > > > to some high value somehow, and the length is being set to 0. > > > > how do you compile the example (which command rdmd, use dub, dmd, ldc ...)? > > I used rdmd myself. This could be a problem. Rdmd could use ldc by default. On archlinux IT use ldc for dub and rdmd.
Comment #9 by dlang-bugzilla — 2015-05-17T05:05:53Z
Comment #10 by bugzilla — 2015-06-26T10:18:50Z
Comment #11 by github-bugzilla — 2015-06-26T11:43:37Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b53c44ed001b113c2f44cf7590ef28630398a5df fix Issue 14430 - [REG2.060] Null parameter is detected as non-null https://github.com/D-Programming-Language/dmd/commit/1ea328e298a9f6ee887917b62b34d32d8e109a0c Merge pull request #4775 from WalterBright/fix14430 fix Issue 14430 - [REG2.060] Null parameter is detected as non-null
Comment #12 by github-bugzilla — 2015-06-26T14:11:55Z
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d6a13be63392ea2d6c2eac369a8b6e2c42b2492b Merge pull request #4775 from WalterBright/fix14430 fix Issue 14430 - [REG2.060] Null parameter is detected as non-null
Comment #13 by github-bugzilla — 2015-07-24T03:20:13Z
Comment #14 by github-bugzilla — 2015-10-04T18:18:41Z
Comment #15 by github-bugzilla — 2017-07-22T12:35:39Z
Commits pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b53c44ed001b113c2f44cf7590ef28630398a5df fix Issue 14430 - [REG2.060] Null parameter is detected as non-null https://github.com/dlang/dmd/commit/1ea328e298a9f6ee887917b62b34d32d8e109a0c Merge pull request #4775 from WalterBright/fix14430