Bug 13777 – Value range propagation faild on array function argument
Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-26T10:31:00Z
Last change time
2014-12-05T15:01:38Z
Keywords
rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2014-11-26T10:31:00Z
This code used to work:
---
T select(T)(in size_t idx, T[2] values...)
{
return values[idx];
}
void main()
{
ubyte ub = select(0, 3, 4);
}
---
In case it was an accept-invalid bug, a clear reason to disallow the feature should be stated as it breaks user code without any deprecation cycle.
Comment #1 by bearophile_hugs — 2014-11-26T10:46:47Z
(In reply to Denis Shelomovskij from comment #0)
> In case it was an accept-invalid bug,
I doubt it was an accept-invalid bug.
Comment #2 by k.hara.pg — 2014-11-28T06:40:15Z
(In reply to Denis Shelomovskij from comment #0)
> This code used to work:
> ---
> T select(T)(in size_t idx, T[2] values...)
> {
> return values[idx];
> }
>
> void main()
> {
> ubyte ub = select(0, 3, 4);
> }
> ---
With 2.057 to 2.066 and git-head, the code fails to compile because T is deduced to int and an int function return is not always implicitly convertible to ubyte.
Which dmd version had you used? If the code has been accepted with certain dmd release, it was definitely an accepts-invalid bug.
> In case it was an accept-invalid bug, a clear reason to disallow the feature
> should be stated as it breaks user code without any deprecation cycle.
Bugfix does not need deprecation cycle.
Comment #3 by bearophile_hugs — 2014-11-28T08:56:07Z
(In reply to Kenji Hara from comment #2)
> With 2.057 to 2.066 and git-head, the code fails to compile because T is
> deduced to int and an int function return is not always implicitly
> convertible to ubyte.
I missed that. So do we close this report as invalid?
Comment #4 by k.hara.pg — 2014-11-28T14:11:28Z
(In reply to bearophile_hugs from comment #3)
> (In reply to Kenji Hara from comment #2)
>
> > With 2.057 to 2.066 and git-head, the code fails to compile because T is
> > deduced to int and an int function return is not always implicitly
> > convertible to ubyte.
>
> I missed that. So do we close this report as invalid?
Maybe, but I'd like to wait Denis's reply.