Bug 3794 – Phobos' socket.receive should assert on the length of the target array
Status
RESOLVED
Resolution
WONTFIX
Severity
minor
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-02-11T15:18:00Z
Last change time
2014-02-22T05:15:51Z
Assigned to
nobody
Creator
default_357-line
Comments
Comment #0 by default_357-line — 2010-02-11T15:18:13Z
A common mistake seems to be passing an empty array to .receive, in the assumption that it will be resized. It would be better to assert on the array length before passing it to the C socket function.
Comment #1 by dlang-bugzilla — 2011-08-23T19:09:04Z
It's probably too late to change this now. WONTFIX?
Also, it would probably have to be an enforce, not an assert.
By the way, the function already special-cased 0-length arrays, by always returning 0 instead of passing it to the C socket function.
> A common mistake
Citation needed ;)
Comment #2 by peter.alexander.au — 2014-02-15T13:09:50Z
I propose we close this as WONTFIX. As Vladimir says, the function handles it safely, and there may be code out there relying on this.
If there are no objections within a week, I'll close it.
Comment #3 by stanislav.blinov — 2014-02-15T15:12:30Z
(In reply to comment #2)
> I propose we close this as WONTFIX. As Vladimir says, the function handles it
> safely, and there may be code out there relying on this.
>
> If there are no objections within a week, I'll close it.
I agree.
The function signature already indicates that no resizing is performed (it's void[], not ref void[]), so the assumption itself is unsubstantiated.
Comment #4 by peter.alexander.au — 2014-02-22T05:15:51Z
As per above discussion, closing this as WONTFIX because:
1. There is no evidence this is a common bug.
2. The code already handles 0-length arrays.
3. There may be user code relying in the current behaviour.