Skip to content

Endian-aware native pointer readers instantiate the wrong pointer type #188

Closed

Description

@dimensionscape

The endian-aware pointer readers in include/cpp/marshal/Marshal.hpp call readPointer<T*> even though readPointer already returns cpp::Pointer. Instantiating the reader therefore produces Pointer<T*> where the declared return type is Pointer.

A compile-only probe against checkout 8d3b460 reproduces this on Linux x86_64 with g++ and HXCPP_API_LEVEL=500:

#include <hxcpp.h>
void probe(const cpp::marshal::View<uint8_t>& bytes) {
    auto p = cpp::marshal::Marshal::readLittleEndianPointer<int>(bytes);
    (void)p;
}

The diagnostic is:

could not convert ... from Pointer<int*> to Pointer<int>

Both readLittleEndianPointer and readBigEndianPointer use the extra pointer level, including their byte-swapping branches. Header inclusion alone does not instantiate these templates, so ordinary builds can miss the problem.

Call readPointer for a pointer-to-T result. Also verify that byte swapping acts on the native pointer representation rather than assuming cpp::Pointer's wrapper representation is the serialized data format. The write methods already operate on value.ptr.

Add compile and round-trip tests that instantiate both endian readers with concrete pointee types. Cover the host-endian and opposite-endian branches. A big-endian hardware run has not been performed here.

Activity

  1. added
    haxe 5Only affects Haxe 5 (API level 500); fixable here, needs Haxe 5 to test
    on Oct 19, 2026
  2. added a commit that references this issue on Oct 20, 2026
    0944a62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    haxe 5Only affects Haxe 5 (API level 500); fixable here, needs Haxe 5 to test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions