Jump to page: 1 2
Thread overview
[Issue 13294] [IFTI] IFTI fails or works incorrectly for function with const and mutable `ref` parameters of most types
Aug 15, 2014
Denis Shelomovskij
Aug 15, 2014
Denis Shelomovskij
Aug 15, 2014
Denis Shelomovskij
Aug 15, 2014
Vladimir Panteleev
Aug 22, 2014
Marc Schütz
Aug 22, 2014
Paul D. Anderson
Aug 25, 2014
Denis Shelomovskij
Aug 25, 2014
Denis Shelomovskij
Aug 25, 2014
Kenji Hara
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|[IFTI] IFTI fails for       |[IFTI] IFTI fails or works
                   |function with const and     |incorrectly for function
                   |mutable `ref` parameters of |with const and mutable
                   |`[u]byte`/`[u]short`        |`ref` parameters of most
                   |                            |types

--- Comment #1 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
It's not just these four integral types. For most other types `const` is incorrectly added. This code should compile fine:
---
void f(T)(const ref T src, ref T dest) // T is const char here
{
    static assert(!is(T == const)); // fails
}

void main()
{
    const char src;
    char dest;
    f(src, dest);
}
---

Note: static assert passes for `int`/`uint`/`long`/`ulong` and floating point types.

--
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE

--- Comment #2 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
(In reply to Denis Shelomovskij from comment #1)
> For most other types `const` is incorrectly added.

And because of CTFE bug 13295 all modifications of such variables disappear, thus in worst case causing nasty wrong-code bugs.

--
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

--- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
(In reply to Denis Shelomovskij from comment #2)
> (In reply to Denis Shelomovskij from comment #1)
> > For most other types `const` is incorrectly added.
> 
> And because of CTFE issue 13295 all modifications of such variables disappear, thus in worst case causing nasty wrong-code bugs.

But as some modifications disappear anyway (because of issue 13297) and thus one can't reliably use `ref` in CTFE it's probably isn't that big problem.

--
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

--- Comment #4 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Introduced in https://github.com/D-Programming-Language/dmd/pull/3801

--
August 22, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

Marc Schütz <schuetzm@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schuetzm@gmx.net

--- Comment #5 from Marc Schütz <schuetzm@gmx.net> ---
User Xinok report a problem on the forums, which is probably related to this
bug:
http://forum.dlang.org/post/bnwtzwmqnrhpvwvxnzkn@forum.dlang.org

--
August 22, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

Paul D. Anderson <paul.d.anderson@comcast.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz@gmail.com

--- Comment #6 from Paul D. Anderson <paul.d.anderson@comcast.net> ---
*** Issue 13351 has been marked as a duplicate of this issue. ***

--
August 25, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

--- Comment #7 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
(In reply to Paul D. Anderson from comment #6)
> *** Issue 13351 has been marked as a duplicate of this issue. ***

So here is testcase for those issue:
---
void f1(T)(in T) { T t; ++t; }
void f2(T)(in T, in T) { T t; ++t; } // (line 2)

void main()
{
    const double n;
    f1(n);     // ok
    f2(n, n);  // error (line 8)
}
---
main.d(2): Error: cannot modify const expression nan
main.d(8): Error: template instance main.f2!(const(double)) error instantiating
---

Compiler carries in case there is more than one argument.

--
August 25, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

--- Comment #8 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
(In reply to Denis Shelomovskij from comment #7)
> ...carries in case...

*carries `const` in case

--
August 25, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|CTFE                        |pull

--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/3896

--
August 25, 2014
https://issues.dlang.org/show_bug.cgi?id=13294

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
« First   ‹ Prev
1 2