Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 11, 2021 can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Hello. I am using dmd 2.094.1 on linux for compiling a piece code I found on the github. Unfortunately linker can't link it as it can't find opCall symbol instantiation demangled as: pure nothrow @nogc @safe bool app.IsEqual!(char).IsEqual.opCall(in char, in char) Do you have any ideas on: 1. Why compiler searches for such function attributes - pure nothrow @nogc @safe, as I don't specify them. Is this a bug or feature?) 2. What changes are needed to compile this rather simple example. Please, help me! Reference to my piece of code in app.d: struct IsEqual(T) { static bool opCall( in T p1, in T p2 ) { return p1 == p2; } } size_t find(T, Pred = IsEqual!(T)) (in T[] haystack, in T needle, Pred pred = Pred.init) { foreach ( pos, cur; haystack ) { if( pred( cur, needle ) ) return pos; } return haystack.length; } int main(string[] args) { auto pos = find("abc" , 'b'); assert(pos == 1); return 0; } Linker error message: Linking... /usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-dmd_2094-BD99179F1B52B13DDA1C2B0172F5081E/app.bin.o: in function `_D3app__T4findTaTSQq__T7IsEqualTaZQlZQBcFNaNbNiNfIAaIaQBlZm': source/app.d:15: undefined reference to `_D3app__T7IsEqualTaZQl6opCallFNaNbNiNfIaIaZb' collect2: error: ld returned 1 exit status ddemangle output on these symbols: _D3app__T7IsEqualTaZQl6opCallFNaNbNiNfIaIaZb pure nothrow @nogc @safe bool app.IsEqual!(char).IsEqual.opCall(in char, in char) _D3app__T4findTaTSQq__T7IsEqualTaZQlZQBcFNaNbNiNfIAaIaQBlZm pure nothrow @nogc @safe ulong app.find!(char, app.IsEqual!(char).IsEqual).find(in char[], in char, app.IsEqual!(char).IsEqual) Thanks you! |
March 11, 2021 Re: can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iliya | On 3/11/21 8:41 AM, Iliya wrote: > I am using dmd 2.094.1 on linux Your program links fine for me with 2.094.2 on Linux. Ali |
March 11, 2021 Re: can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Thursday, 11 March 2021 at 17:25:35 UTC, Ali Çehreli wrote: > On 3/11/21 8:41 AM, Iliya wrote: > > > I am using dmd 2.094.1 on linux > > Your program links fine for me with 2.094.2 on Linux. > > Ali Thank you, Ali! I also played with it on playground. Seems that it is a bug. The compilation results: Up to 2.093.1: Success and no output Since 2.094.1: Failure with output: ----- onlineapp.o: In function `_D9onlineapp__T4findTaTSQw__T7IsEqualTaZQlZQBcFNaNbNiNfIAaIaQBlZm': /sandbox/onlineapp.d:15: undefined reference to `_D9onlineapp__T7IsEqualTaZQl6opCallFNaNbNiNfIaIaZb' collect2: error: ld returned 1 exit status Error: linker exited with status 1 ----- |
March 12, 2021 Re: can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iliya | Try it with: -allinst It may just be deciding a template instance isn't required. |
March 17, 2021 Re: can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Thursday, 11 March 2021 at 17:41:27 UTC, rikki cattermole wrote:
> Try it with:
>
> -allinst
>
> It may just be deciding a template instance isn't required.
Good workaround for such kind of bugs! )
Up to 2.063 : Failure with output: Error: unrecognized switch '-allinst'
Since 2.064 : Success and no output
|
March 17, 2021 Re: can't link a code, is it a bug or my fault? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Thursday, 11 March 2021 at 17:41:27 UTC, rikki cattermole wrote:
> Try it with:
>
> -allinst
>
> It may just be deciding a template instance isn't required.
The error message could maybe be changed to include this? "Try -allinst bla bla"
|
Copyright © 1999-2021 by the D Language Foundation