[Issue 3467] Non-int integral template parameters not correctly propagated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 23 16:28:08 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3467
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> 2011-11-23 16:27:10 PST ---
(In reply to comment #4)
> I believe this is not a bug. The type of a template is based on what its
> argument types are, not its parameter types. Hence,
>
> foo!3
>
> is always a different type from:
>
> foo!3u
>
> even if foo is defined to take an int parameter.
The issue is that the foo template with signed integer makes incorrect
instantiation internally.
There are two solutions:
1. Makes that instantiation invalid.
2. Promote signed integer template value parameter into unsigned.
My patch implements #2, and I believe that is correct.
Because non-suffix integer literal can implicitly convertible to unsigned.
And, my patch doesn't break existing code around template overloading.
Following code still valid.
template Foo(int n){ enum Foo = 1; }
template Foo(uint n){ enum Foo = 2; }
static assert(Foo!10 == 1);
static assert(Foo!10u == 2);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list