mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Missing end padding when including a packed struct #1966.
This commit is contained in:
48
test/test_suite/struct/struct_pack_error.c3t
Normal file
48
test/test_suite/struct/struct_pack_error.c3t
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user