I use __int128
as struct's member.
It works find with -O0
(no optimization).
However it crashes for segment fault if optimization enabled (-O1
).
It crashes at instruction movdqa
, which need the var aligned by 16.
While the address is allocated by malloc()
which align only by 8.
I tried to disable SSE optimization by -mno-sse
, but it fails to compile:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:27:1: error: SSE register return with SSE disabled
So what can I do if I want to use __int128
and -O1
both?
Thanks in advance Wu
BTW, it seems OK if __int128
is used only on stack (not on heap).
==== EDIT ====
Sorry that I did not say the truth.
In fact I did not use malloc()
. I used a memory pool lib which returns address aligned by 8.
I said malloc()
just to want to make things simple.
After testing, I have known that malloc()
aligns by 16. And the __int128
member also align by 16 in struct.
So the problem is my memory pool lib only.
Thanks very much.
alignof(maxalign_t) == 16
somalloc
always returns 16-byte aligned pointers. It sounds like yourmalloc
is broken, and would violate the ABI if used forlong double
as well.malloc
is guaranteed to be aligned enough to hold any standard type. This can't be 32-bit code, because gcc doesn't support__int128
in 32-bit targets. – Tobacconistmalloc()
align by 8. Thanks. – Franni