Bug 9198 – Vararg functions don't respect IFTI rules

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-23T01:49:00Z
Last change time
2013-06-08T00:40:08Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
monarchdodra

Comments

Comment #0 by monarchdodra — 2012-12-23T01:49:23Z
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.
Comment #1 by k.hara.pg — 2012-12-23T03:38:28Z
(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.
Comment #2 by k.hara.pg — 2012-12-23T04:08:09Z
Comment #3 by github-bugzilla — 2013-01-08T21:20:30Z
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
Comment #4 by monarchdodra — 2013-06-08T00:40:08Z
(In reply to comment #2) > https://github.com/D-Programming-Language/dmd/pull/1399 Thankyou for having fixed this.