digitalmars.D.learn - Template error with gdc-10 but not with latest dmd and ldc
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (17/17) Jul 26 2020 The code example
- rikki cattermole (18/18) Jul 26 2020 Old frontend:
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (10/30) Jul 26 2020 I don't understand.
- Iain Buclaw (3/10) Jul 26 2020 This feature?
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/4) Jul 26 2020 I see. Thanks.
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (7/8) Jul 26 2020 The code
The code example long add_long_n0(alias T=void)(long x) safe pure nothrow nogc { return x + 0; } int main(string[] args) { long long_sum = 0; long_sum += add_long_n0!(void)(cast(long)0); return cast(int)long_sum; } compiles without errors with dmd and ldc. But with gdc-10 as gdc -c linear_t.d it errors as linear_t.d:6:17: error: template instance add_long_n0!() does not match template declaration add_long_n0(alias T = void)(long x) 6 | long_sum += add_long_n0!()(cast(long)0); | ^ Why can't LDC handle such a trivial template example?
Jul 26 2020
Old frontend: Up to 2.060 : Failure with output: onlineapp.d(2): Error: valid attribute identifiers are property, safe, trusted, system, disable not nogc 2.061 to 2.065.0: Failure with output: ----- onlineapp.d(2): Error: user defined attributes cannot appear as postfixes onlineapp.d(2): Error: semicolon expected following function declaration onlineapp.d(2): Error: Declaration expected, not 'return' onlineapp.d(2): Error: unrecognized declaration ----- 2.066.0 to 2.078.1: Failure with output: onlineapp.d(7): Error: template instance add_long_n0!void does not match template declaration add_long_n0(alias T = void)(long x) 2.079.1 to 2.086.1: Failure with output: onlineapp.d(7): Error: template instance `add_long_n0!void` does not match template declaration `add_long_n0(alias T = void)(long x)` Since 2.087.1: Success and no output
Jul 26 2020
On Sunday, 26 July 2020 at 19:27:13 UTC, rikki cattermole wrote:Old frontend: Up to 2.060 : Failure with output: onlineapp.d(2): Error: valid attribute identifiers are property, safe, trusted, system, disable not nogc 2.061 to 2.065.0: Failure with output: ----- onlineapp.d(2): Error: user defined attributes cannot appear as postfixes onlineapp.d(2): Error: semicolon expected following function declaration onlineapp.d(2): Error: Declaration expected, not 'return' onlineapp.d(2): Error: unrecognized declaration ----- 2.066.0 to 2.078.1: Failure with output: onlineapp.d(7): Error: template instance add_long_n0!void does not match template declaration add_long_n0(alias T = void)(long x) 2.079.1 to 2.086.1: Failure with output: onlineapp.d(7): Error: template instance `add_long_n0!void` does not match template declaration `add_long_n0(alias T = void)(long x)` Since 2.087.1: Success and no outputI don't understand. I removed the qualifiers but still get the same error from this unqualified code: long add_long_n0(alias T=void)(long x) { return x + 0; } int main(string[] args) { long long_sum = 0; long_sum += add_long_n0!(void)(0); return cast(int)long_sum; }
Jul 26 2020
On Sunday, 26 July 2020 at 19:27:13 UTC, rikki cattermole wrote:2.066.0 to 2.078.1: Failure with output: onlineapp.d(7): Error: template instance add_long_n0!void does not match template declaration add_long_n0(alias T = void)(long x) 2.079.1 to 2.086.1: Failure with output: onlineapp.d(7): Error: template instance `add_long_n0!void` does not match template declaration `add_long_n0(alias T = void)(long x)` Since 2.087.1: Success and no outputThis feature? https://dlang.org/changelog/2.087.0.html#template_alias_matches_basic_types
Jul 26 2020
On Sunday, 26 July 2020 at 20:32:55 UTC, Iain Buclaw wrote:This feature? https://dlang.org/changelog/2.087.0.html#template_alias_matches_basic_typesI see. Thanks.
Jul 26 2020
On Sunday, 26 July 2020 at 21:48:09 UTC, Per Nordlöw wrote:I see. Thanks.The code long add_long_n0(alias T=void)(long x) { return x + 0; } should be long add_long_n0(T=void)(long x) { return x + 0; } . My mistake. Thanks.
Jul 26 2020