Thread overview
[Issue 9198] New: Vararg functions don't respect IFTI rules
Dec 23, 2012
Kenji Hara
Dec 23, 2012
Kenji Hara
Jan 09, 2013
Walter Bright
December 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9198

           Summary: Vararg functions don't respect IFTI rules
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: monarchdodra@gmail.com


--- Comment #0 from monarchdodra@gmail.com 2012-12-23 01:49:23 PST ---
I'm not sure *what* said rules are, but as observed here: https://github.com/D-Programming-Language/phobos/pull/1010#discussion_r2418181

The root issue is that IFTI should cast an immutable slice to a slice of immutables, but that doesn't happen with varargs:

//----
import std.stdio;

void foo1(Range)(Range)
{
    writeln("Foo1: ", Range.stringof);
}
void foo2(Ranges...)(Ranges)
{
    writeln("Foo2: ", Ranges[0].stringof);
}

void main()
{
    immutable(int[]) a = [1, 2, 3];

    foo1(a);
    foo2(a);
}
//----
Foo1: immutable(int)[]
Foo2: immutable(int[])
//----

I'm not sure what the rules are, but I'd expect seeing something consistent in any case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9198



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-23 03:38:28 PST ---
(In reply to comment #0)
> I'm not sure *what* said rules are, but as observed here: https://github.com/D-Programming-Language/phobos/pull/1010#discussion_r2418181
> 
> The root issue is that IFTI should cast an immutable slice to a slice of immutables, but that doesn't happen with varargs:
> 
[snip]
> 
> I'm not sure what the rules are, but I'd expect seeing something consistent in any case.

This behavior has been introduced from 2.057.

http://dlang.org/changelog#new2_057
> Removed top const from dynamic array types and pointer types in IFTI.

https://github.com/d-programming-language/dmd/commit/cc0cde2345e6921fc28bd688a503b03fc98f8b93

And, from the view of implementer, this behavior is definitely a bug. Because I did consider nothing about variadic template parameter.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9198


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
            Version|unspecified                 |D2


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-23 04:08:09 PST ---
https://github.com/D-Programming-Language/dmd/pull/1399

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9198



--- Comment #3 from github-bugzilla@puremagic.com 2013-01-08 21:20:30 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b038f56c3639d98c0c0931e0dd74c204bf1320cc fix Issue 9198 - Vararg functions don't respect IFTI rules

https://github.com/D-Programming-Language/dmd/commit/5f5ec2791a5cb4d68cfeb632750b29f99f7ec052 Merge pull request #1399 from 9rnsr/fix9198

Issue 9198 - Vararg functions don't respect IFTI rules

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9198


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9198



--- Comment #4 from monarchdodra@gmail.com 2013-06-08 00:40:08 PDT ---
(In reply to comment #2)
> https://github.com/D-Programming-Language/dmd/pull/1399

Thankyou for having fixed this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------