Skip to content

RID causes native structures to be misaligned #1956

Description

@BenLubar

Godot version

c2fe519aa640991b7197008b2793dc2e18c71d77 (there are some custom changes but this is a compile time bug)

godot-cpp version

9ae37ac

System information

Linux, compiling for wasm32

Issue description

#include <godot_cpp/classes/glyph.hpp>

The RID field in godot::Glyph is aligned incorrectly.

Steps to reproduce

A correctly laid out struct would be this, or changing RID to be aligned properly in general:

struct Glyph {
	int start = -1;
	int end = -1;

	uint8_t count = 0;
	uint8_t repeat = 1;
	uint16_t flags = 0;

	float x_off = 0.f;
	float y_off = 0.f;
	float advance = 0.f;

	alignas(uint64_t) RID font_rid;
	int font_size = 0;
	int32_t index = 0;

	int span_index = -1;
};

Minimal reproduction project

N/A

Activity

  1. dsnopek commented on Mar 24, 2026

    @dsnopek
    Collaborator

    I just posted #1958 which should fix this. Please give it a try!

  2. added
    bug
    on Mar 24, 2026
  3. BenLubar commented on Oct 13, 2026

    @BenLubar
    ContributorAuthor

    RID (and uint64_t) on 32-bit x86 Linux is 8 bytes, aligned to 4 bytes.

  4. BenLubar commented on Oct 14, 2026

    @BenLubar
    ContributorAuthor

    @dsnopek Looks like RID is the only Variant type that is more than 4 bytes on 32-bit, isn't hard-coded in godot-cpp, and also doesn't have an explicit alignas in Godot, so this could be fixed by adding an if in the binding generator to specifically make RID alignas(uint64_t) rather than alignas(8).

    This only affects structs containing RID, so unless someone else is using godot::Glyph this is low priority.

    And godot::Glyph in godot-cpp has been broken since Godot 4.4, so I think I'm the only one currently using it. godotengine/godot#124451

    Edit: Packed arrays! PackedStringArray is a Vector<String>, which is struct { struct{}; CowData<String>; } which means it's 8 bytes with 4 byte alignment too.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions