www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - undefined reference to `const const(char)[] object.Throwable.message()

reply kdevel <kdevel vogtner.de> writes:
I am compiling some test code which dmd v2.100.and linking 
against a libdecimal.a compiled in March, probably compiled with 
dmd v2.099.0.

```
    $ dmd -g mytest.d decimal.git/libdecimal.a
```

Now the linker complains:

```
decimal.git/libdecimal.a(decimal_4f_a27.o):(.data._D7decimalQi25InvalidOperationExce
tion6__vtblZ+0x48): undefined reference to `_D6object9Throwable7messageMxFZAxa'
decimal.git/libdecimal.a(decimal_50_94f.o):(.data._D7decimalQi23DivisionByZeroExce
tion6__vtblZ+0x48): undefined reference to `_D6object9Throwable7messageMxFZAxa'
decimal.git/libdecimal.a(decimal_51_703.o):(.data._D7decimalQi17OverflowExce
tion6__vtblZ+0x48): undefined reference to `_D6object9Throwable7messageMxFZAxa'
decimal.git/libdecimal.a(decimal_52_765.o):(.data._D7decimalQi18UnderflowExce
tion6__vtblZ+0x48): undefined reference to `_D6object9Throwable7messageMxFZAxa'
decimal.git/libdecimal.a(decimal_53_67b.o):(.data._D7decimalQi16InexactExce
tion6__vtblZ+0x48): undefined reference to `_D6object9Throwable7messageMxFZAxa'
decimal.git/libdecimal.a(decimal_4e_65e.o):(.data._D7decimalQi16DecimalExce
tion6__vtblZ+0x48): more undefined references to
`_D6object9Throwable7messageMxFZAxa' follow
collect2: ld returned 1 exit status
Error: linker exited with status 1
```

which demangles to

```
decimal.git/libdecimal.a(decimal_4e_65e.o):(.data.decimal.decimal.DecimalExc
ption.__vtbl+0x48): more undefined references to `const const(char)[]
object.Throwable.message()' follow
```

When switching back to dmd v2.099.1 linking succeeds. Could not 
find any hint in https://dlang.org/changelog/2.100.0.html.
May 17 2022
parent rikki cattermole <rikki cattermole.co.nz> writes:
As far as I know, no D compiler guarantees compatibility between objects 
built on different version of itself.

The change would have been[0].

[0] 
https://github.com/dlang/druntime/commit/c6762914682d4fa894e2b746bf4bd9ce3ec9f7cb
May 17 2022