digitalmars.D.ldc - Error: Incompatible declaration of runtime function `_d_arraybounds`
- Adam D. Ruppe (8/8) Aug 23 2020 A little known fact is dmd actually provides index and length for
- kinke (6/15) Aug 23 2020 Such hacks don't work with LDC and its strongly typed IR, so we
- kinke (1/1) Aug 23 2020 [e2ir.d is part of DMD's glue layer, not included by LDC.]
- Adam D. Ruppe (5/11) Aug 23 2020 Blargh.
- Kagamin (3/5) Aug 27 2020 Just call the extended function _d_arraybounds2 and you can live
- David Nadlinger (14/16) Aug 23 2020 Use grep. :P
A little known fact is dmd actually provides index and length for RangeError in e2ir.d, but druntime doesn't do anything with it. I just tried defining an object.d in ldc with this: extern(C) void _d_arraybounds(string file, size_t line, size_t lwr, size_t upr, size_t length) {} to take advantage of this data and ldc outright rejected it. I don't really know my way around the ldc source... what can I do about this?
Aug 23 2020
On Sunday, 23 August 2020 at 13:25:30 UTC, Adam D. Ruppe wrote:A little known fact is dmd actually provides index and length for RangeError in e2ir.d, but druntime doesn't do anything with it. I just tried defining an object.d in ldc with this: extern(C) void _d_arraybounds(string file, size_t line, size_t lwr, size_t upr, size_t length) {} to take advantage of this data and ldc outright rejected it. I don't really know my way around the ldc source... what can I do about this?Such hacks don't work with LDC and its strongly typed IR, so we don't pass these unused extra args. You can grep the src for `_d_arraybounds`, adjusting the signature of this runtime hook and the call site in DtoBoundsCheckFailCall(), but will have to adapt more code to forward the extra args to the latter function.
Aug 23 2020
[e2ir.d is part of DMD's glue layer, not included by LDC.]
Aug 23 2020
On Sunday, 23 August 2020 at 13:41:18 UTC, kinke wrote:Such hacks don't work with LDC and its strongly typed IR, so we don't pass these unused extra args. You can grep the src for `_d_arraybounds`, adjusting the signature of this runtime hook and the call site in DtoBoundsCheckFailCall(), but will have to adapt more code to forward the extra args to the latter function.Blargh. I plan to get that info used in upstream dmd druntime eventually, but meh I'll keep living in darkness for now. oh well
Aug 23 2020
On Sunday, 23 August 2020 at 14:19:13 UTC, Adam D. Ruppe wrote:I plan to get that info used in upstream dmd druntime eventually, but meh I'll keep living in darkness for now.Just call the extended function _d_arraybounds2 and you can live with both.
Aug 27 2020
On 23 Aug 2020, at 14:25, Adam D. Ruppe via digitalmars-d-ldc wrote:I don't really know my way around the ldc source... what can I do about this?Use grep. :P --- ~/ldc $ rg arraybounds gen/runtime.cpp 554: // void _d_arraybounds(string file, uint line) 555: createFwdDecl(LINKc, Type::tvoid, {"_d_assert", "_d_arraybounds"}, gen/arrays.cpp 1365: getRuntimeFunction(loc, irs->module, "_d_arraybounds"); --- You can add the extra parameters in gen/runtime.cpp (first hit), but you'll also need to update the bounds checking code to emit the extra argument (second hit). — David
Aug 23 2020