Bug 19566 – Warn when the same argument is passed two times, once as ref or out, the other not
Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-01-09T12:24:39Z
Last change time
2019-04-16T01:16:53Z
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2019-01-09T12:24:39Z
stuff like this:
```
void stuff(I,O)(const I input, ref O output){}
void other()
{
ubyte[] data;
stuff(data, data);
}
```
are probably a problem and worth a warn, even if `input` is not const.
Comment #1 by razvan.nitu1305 — 2019-01-11T09:25:31Z
This will most likely be marked as invalid. The reasons are:
1. Walter is against warnings. His position, to which I adhere, is that the compiler should either emit an error or accept the code. Anything in between is speculation and it depends on what you want to do with your code.
2. There is no way that the code in the bug report will error. That is valid code.
3. The check for the general case will come with a performance cost for a niche case.
4. It is a job for static analysis tools to warn us on such code smells, not that of a compiler.
I suggest we close this as invalid.
Comment #2 by apz28 — 2019-04-16T01:16:53Z
This should be an error as below
```
void stuff(I,O)(const I input, out O output){}
void other()
{
ubyte[] data = void;
stuff(data, data);
}
```