Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 10, 2015 duplicate symbols | ||||
---|---|---|---|---|
| ||||
Should the compiler issue an error for this code? struct S { } string generate(S t) { return ""; } string generate(S t) { return "huh?"; } It compiles and breaks with multiple definition of '_D1b8generateFS1b1SZAya' at link time. dmd v2.067 |
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitri Makarov | It will when you try to use this function test.d(18): Error: test.generate called with argument types (S) matches both: test.d(7): test.generate(S t) and: test.d(12): test.generate(S t) On Fri, 10 Apr 2015 09:54:31 +0000 Dmitri Makarov via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > Should the compiler issue an error for this code? > > struct S > { > } > > string generate(S t) > { > return ""; > } > > string generate(S t) > { > return "huh?"; > } > > It compiles and breaks with multiple definition of '_D1b8generateFS1b1SZAya' at link time. dmd v2.067 |
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozák | Fine. Then I expect it not to break the linking when the function is not called. Now it does, albeit only when -cov is used.
On Friday, 10 April 2015 at 10:01:00 UTC, Daniel Kozák wrote:
> It will when you try to use this function
> test.d(18): Error: test.generate called with argument types (S) matches
> both: test.d(7): test.generate(S t)
> and:
> test.d(12): test.generate(S t)
>
>
>
> On Fri, 10 Apr 2015 09:54:31 +0000
> Dmitri Makarov via Digitalmars-d-learn
> <digitalmars-d-learn@puremagic.com> wrote:
>
>> Should the compiler issue an error for this code?
>>
>> struct S
>> {
>> }
>>
>> string generate(S t)
>> {
>> return "";
>> }
>>
>> string generate(S t)
>> {
>> return "huh?";
>> }
>>
>> It compiles and breaks with multiple definition of '_D1b8generateFS1b1SZAya' at link time. dmd v2.067
|
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitri Makarov | The compiler postpones some checks to codegen and link time. |
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | How does this help me to get a working program?
On Friday, 10 April 2015 at 10:08:56 UTC, Kagamin wrote:
> The compiler postpones some checks to codegen and link time.
|
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitri Makarov | On Friday, 10 April 2015 at 10:14:51 UTC, Dmitri Makarov wrote:
> How does this help me to get a working program?
>
> On Friday, 10 April 2015 at 10:08:56 UTC, Kagamin wrote:
>> The compiler postpones some checks to codegen and link time.
To see all errors you should link the code. Then you can fix them.
|
April 10, 2015 Re: duplicate symbols | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitri Makarov | On 4/10/15 5:54 AM, Dmitri Makarov wrote: > Should the compiler issue an error for this code? > > struct S > { > } > > string generate(S t) > { > return ""; > } > > string generate(S t) > { > return "huh?"; > } > > It compiles and breaks with multiple definition of > '_D1b8generateFS1b1SZAya' at link time. dmd v2.067 There's a bug on this: https://issues.dlang.org/show_bug.cgi?id=2789 -Steve |
Copyright © 1999-2021 by the D Language Foundation