Missing end padding when including a packed struct #1966.

This commit is contained in:
Christoffer Lerno
2025-02-13 21:15:27 +01:00
parent 8c58b31bbd
commit cec9b21707
3 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
// #target: macos-x64
module test;
import std;
// issue 1966
struct MsgHeader @packed
{
ulong enqueued_by_router_us;
}
enum ClientState
{
NOT_INITIALIZED,
WAITING_FOR_LOGIN,
READY,
WAITING_FOR_CLOSE,
}
struct Client
{
ClientState state;
MsgHeader header;
ushort service_id;
ElasticArray(<ulong, 1>) subscribers;
}
Client[10] clients;
fn void main()
{
void* a = ((void*)(&clients[0])) + Client.sizeof;
void* b = &clients[1];
}
/* #expect: test.ll
%Client = type <{ i32, %MsgHeader, i16, [2 x i8], %ElasticArray }>
%MsgHeader = type { i64 }
%ElasticArray = type { i64, [1 x i64] }
define void @test.main() #0 {
entry:
%a = alloca ptr, align 8
%b = alloca ptr, align 8
store ptr getelementptr (i8, ptr @test.clients, i64 32), ptr %a, align 8
store ptr getelementptr inbounds (i8, ptr @test.clients, i64 32), ptr %b, align 8
ret void
}