Skip to content

[.net 8][C#] Possible type/memory safety issue? In typeOnlyPseudoCode float = (writes to memory as Vector3) new Vector3(type: struct { float; float; float; }); Vector3 = (read as Vector3)float; #45905

Closed
@ghost

Description

Describe the bug

A clear and concise description of what the bug is.
The only reason I've found this out is, because otherwise my character in Godot doesn't fall through the floor if the type is correct(Vector3).
Haven't noticed, because my project compiled right through;
Vector3 in Godot is of type struct { float; float; float; }.

To Reproduce

  1. In "צלול/Src/Player.cs" replace "private Vector3 camRot = Vector3.Zero;" with "private float camRot = 0.0f;".
    The project will compile.
  2. Now when moving the camera up/down the character can fall through the floor, otherwise it cannot.

We may close this issue if:

  • the repro project you share with us is complex. We can't investigate custom projects, so don't point us to such, please.
  • if we will not be able to repro the behavior you're reporting
    -->
    Idk if it modifies any variables as a result or if the Type of "camRot" changes from "float" to "Vector3", otherwise something fishy is going on?
    https://github.com/espoir-espoir/tsalul
    Of course this is a bit silly, because the whole object is being put upside down as a result of moving the mouse up/down too much.
    Somehow the camera movement is unaffected, other than for that one little thing.
    There are assignments to float from struct {float; float; float;}(basically float[3] ?+ maybe padding?);
    And writes to struct {float; float; float; } from float(but 3 valeus are being read).

I haven't produced a minimal reproducible here, sorry.
So far tried this only on macOS 15.2 and godot 4.3, haven't tested outside of that.

Exceptions (if any)

Not that I know of.

Further technical details

Metadata

Assignees

No one assigned

    Labels

    untriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions