Skip to content

AOT: raw-pointer indexing by int64 emits ambiguous das_index<T*>::at — only int32/uint32 overloads exist #3391

Description

@borisbat

Indexing a raw pointer with an int64 index compiles and runs fine in interpreter and JIT, but the AOT-generated C++ fails to compile:

error: call to 'at' is ambiguous
    das_index<float * const >::at(__rp, __i, __context__)
note: candidate: at ( TT * value, int32_t index, Context * )   // aot.h:891
note: candidate: at ( TT * value, uint32_t index, Context * )  // aot.h:894

int64_t converts to int32_t and uint32_t with equal rank, so clang rejects the call.

Minimal repro (any .das through the AOT emitter):

options gen2
def touch(p : float?; n : int64) : float {
    var s = 0.0
    unsafe {
        for (i in range64(n)) {
            s += p[i]        // AOT: ambiguous
        }
    }
    return s
}

Root cause: the das_index<TT * const> specialization in include/daScript/simulate/aot.h (~line 890) only provides int32_t / uint32_t overloads for at and safe_at. Arrays are not affected — array<T> indexing has 64-bit overloads — it is only raw pointers.

Suggested fix: add int64_t / uint64_t overloads to at and safe_at in the pointer specializations (additive, no ABI concern). Until then the das-side workaround is an int loop or an int(i) cast at the index site.

Hit in practice by diff_stage in modules/dasLLAMA/dasllama/dasllama_audio.das (worked around in #3390, commit 5c412f4); trap documented in skills/aot_testing.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions