D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3210 - Inconsistency in implicit casting of integral template value parameters
Summary: Inconsistency in implicit casting of integral template value parameters
Status: RESOLVED DUPLICATE of issue 3467
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-07-26 03:22 UTC by Robin KAY
Modified: 2014-04-18 09:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robin KAY 2009-07-26 03:22:30 UTC
Given a template T(uint N), int values for N are implicitly cast to uint where N is used within the template body. However, the instantiation of T!(n) precedes the coercion of n to uint such that the template instances T!(1) and T!(1u), and any types defined within them, are distinct. I believe this should not be the case.

Reproduced with DMD 1.046 under Linux and LDC r1522 under Solaris. Test case and compiler output below:
---
module Test;

struct Test(uint N)
{
  int x;

  Test!(N) f(Test!(N) rhs)
  {
    return Test!(N)(x+rhs.x);
  }
}

void main()
{
  Test!(1) x;
  x.f(x);
}
---
Test.d(16): Error: function Test.Test!(1).Test.f (Test!(1u)) does not match parameter types (Test!(1))
Test.d(16): Error: cannot implicitly convert expression (b) of type Test!(1) to Test!(1u)
Comment 1 Kenji Hara 2011-11-28 16:59:59 UTC

*** This issue has been marked as a duplicate of issue 3467 ***