D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6745 - template signature match failure (matrix transpose example)
Summary: template signature match failure (matrix transpose example)
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-09-29 19:05 UTC by marcianx
Modified: 2014-11-06 01:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description marcianx 2011-09-29 19:05:20 UTC
I tried this on the DMD64 D compiler v2.055 on linux. The valid D code at the bottom fails with the following errors when I invoke 
--------------
$ dmd template_match_bug.d
template_match_bug.d(29): Error: template template_match_bug.mat_vec_mult_ret(int M,int N) does not match any function template declaration
template_match_bug.d(29): Error: template template_match_bug.mat_vec_mult_ret(int M,int N) cannot deduce template function from argument types !()(MatrixT!(N,M),VectorT!(3),VectorT!(2))
--------------
If I comment out the definition of transposed() or the alias definition of Mat32 (which itself is never used), then the program compiles without error. When both are present, the bug is triggered.


--------------
struct VectorT(int N) { }

struct MatrixT(int M, int N)
{
    // Bug trigger #1
    MatrixT!(N,M) transposed() const {
        return MatrixT!(N,M)();
    }
}

void mat_vec_mult_ret(int M,int N)(
    auto ref MatrixT!(M,N) A, 
    auto ref VectorT!(N) x,
    ref VectorT!(M) ret)
{
}

void main(string[] args)
{
    alias MatrixT!(3,2) Mat32; // Bug trigger #2
    alias MatrixT!(2,3) Mat23;
    alias VectorT!(3) Vec3;
    alias VectorT!(2) Vec2;

    Vec3 x;
    Vec2 Ax;
    Mat23 mat23;

    mat_vec_mult_ret(mat23, x, Ax);
}
--------------
Comment 1 hsteoh 2014-11-06 01:42:46 UTC
Tested on git HEAD, Linux/64. The compiler now accepts this code, looks like it's been fixed since. Please reopen if it still happens. Thanks!