digitalmars.D.learn - can't link a code, is it a bug or my fault?
- Iliya (52/52) Mar 11 2021 Hello.
- =?UTF-8?Q?Ali_=c3=87ehreli?= (3/4) Mar 11 2021 Your program links fine for me with 2.094.2 on Linux.
- Iliya (14/18) Mar 11 2021 Thank you, Ali!
- rikki cattermole (3/3) Mar 11 2021 Try it with:
- Iliya (6/9) Mar 17 2021 Good workaround for such kind of bugs! )
- Imperatorn (4/7) Mar 17 2021 The error message could maybe be changed to include this? "Try
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-BD99179F1B52B13DDA1C2B0 72F5081E/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!
Mar 11 2021
On 3/11/21 8:41 AM, Iliya wrote:I am using dmd 2.094.1 on linuxYour program links fine for me with 2.094.2 on Linux. Ali
Mar 11 2021
On Thursday, 11 March 2021 at 17:25:35 UTC, Ali Çehreli wrote:On 3/11/21 8:41 AM, Iliya wrote: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 -----I am using dmd 2.094.1 on linuxYour program links fine for me with 2.094.2 on Linux. Ali
Mar 11 2021
Try it with: -allinst It may just be deciding a template instance isn't required.
Mar 11 2021
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
Mar 17 2021
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"
Mar 17 2021