5
4
Fork
You've already forked celes-bootstrap
1

sub-expressions of or-chains get lost #1

Closed
opened 2026年05月04日 23:55:25 +02:00 by skolin · 1 comment

I had encountered a bug when "manually" concatenating bytes into an int:

fn as_int(r: i32,g: i32,b: i32)-> i32 {((r&0xFF)<<24)|((r&0xFF)<<16)|(r&0xFF)|0xFF}

transpiled into:

static int32_t cel_celes_as_int(int32_t r, int32_t g, int32_t b)
{
	return (r & 0xFF) | 0xFF;
}

I had to shift in each byte as its own expression for it to work:

fn as_int(r: i32,g: i32,b: i32)-> i32 {letmutres: i32 =255;res=res|((r&0x0FF)<<24);res=res|((g&0x0FF)<<16);res=res|((b&0x0FF)<<8);returnres;}

Haven't looked further into it though, not sure what caused it.

I had encountered a bug when "manually" concatenating bytes into an int: ```rust fn as_int(r: i32, g: i32, b: i32) -> i32 { ((r & 0xFF) << 24) | ((r & 0xFF) << 16) | (r & 0xFF) | 0xFF } ``` transpiled into: ```c static int32_t cel_celes_as_int(int32_t r, int32_t g, int32_t b) { return (r & 0xFF) | 0xFF; } ``` I had to shift in each byte as its own expression for it to work: ```rust fn as_int(r: i32, g: i32, b: i32) -> i32 { let mut res: i32 = 255; res = res | ((r & 0x0FF) << 24); res = res | ((g & 0x0FF) << 16); res = res | ((b & 0x0FF) << 8); return res; } ``` Haven't looked further into it though, not sure what caused it.
Collaborator
Copy link

Should be fixed here: 2a0f4651f3

Should be fixed here: https://codeberg.org/LainVT/celes-bootstrap/commit/2a0f4651f38b0a4f718ab1658392d6992927f2c8
Sign in to join this conversation.
No Branch/Tag specified
main
temp-stuff
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LainVT/celes-bootstrap#1
Reference in a new issue
LainVT/celes-bootstrap
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?