Open eli-schwartz opened 3 months ago
Thanks for the report. I agree these should be fixed.
Using the command ./buildold LIBS netlrts-linux-x86_64-smp -k -j4 -g3 -O2 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
, I was able to get a longer list of strict-aliasing violations:
queueing.C: In function ‘void CqsEnqueueGeneral(Queue, void*, int, int, unsigned int*)’:
queueing.C:682:16: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
682 | lprio =(((CmiUInt4 *)&lprio0)[0]*1LL)<<CINTBITS | ((CmiUInt4 *)&lprio0)[1];
| ~^~~~~~~~~~~~~~~~~~~~
queueing.C:697:16: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
697 | lprio =(((CmiUInt4 *)&lprio0)[0]*1LL)<<CINTBITS | ((CmiUInt4 *)&lprio0)[1];
| ~^~~~~~~~~~~~~~~~~~~~
In file included from sockRoutines.h:128,
from conv-ccs.h:10,
from debug-conv.C:12:
debug-conv.C: In function ‘void CpdSearchLeaks(char*)’:
debug-conv.C:83:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
83 | (((CmiUInt8)ntohl(((int*)&info->begin_data)[0]))<<32) + ntohl(((int*)&info->begin_data)[1]));
| ~^~~~~~~~~~~~~~~~~~~~~~~~
debug-conv.C:85:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
85 | (((CmiUInt8)ntohl(((int*)&info->end_data)[0]))<<32) + ntohl(((int*)&info->end_data)[1]));
| ~^~~~~~~~~~~~~~~~~~~~~~
debug-conv.C:87:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
87 | (((CmiUInt8)ntohl(((int*)&info->begin_bss)[0]))<<32) + ntohl(((int*)&info->begin_bss)[1]));
| ~^~~~~~~~~~~~~~~~~~~~~~~
debug-conv.C:89:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
89 | (((CmiUInt8)ntohl(((int*)&info->end_bss)[0]))<<32) + ntohl(((int*)&info->end_bss)[1]));
| ~^~~~~~~~~~~~~~~~~~~~~
In file included from ccs-builtins.C:14:
pup_toNetwork.h: In member function ‘void* PUP_toNetwork_unpack::read_CMK_POINTER_SIZED_INT()’:
pup_toNetwork.h:117:21: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
117 | return *(void **)&i;
| ^~~~~~~~~~~
In file included from pup_toNetwork.C:11:
pup_toNetwork.h: In member function ‘void* PUP_toNetwork_unpack::read_CMK_POINTER_SIZED_INT()’:
pup_toNetwork.h:117:21: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
117 | return *(void **)&i;
| ^~~~~~~~~~~
In file included from pup_c.C:14:
pup_toNetwork.h: In member function ‘void* PUP_toNetwork_unpack::read_CMK_POINTER_SIZED_INT()’:
pup_toNetwork.h:117:21: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
117 | return *(void **)&i;
| ^~~~~~~~~~~
In file included from machine.C:209:
machine-eth.C: In function ‘void AssembleDatagram(OtherNode, ExplicitDgram)’:
machine-common-core.C:131:29: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
131 | #define CMI_MSG_SIZE(msg) ((CmiMsgHeaderBasic *)msg)->size
| ~^~~~~~~~~~~~~~~~~~~~~~~~~
machine-eth.C:384:12: note: in expansion of macro ‘CMI_MSG_SIZE’
384 | size = CMI_MSG_SIZE(dg->data);
| ^~~~~~~~~~~~
md/setjmp64_.c: In function ‘qt_args_1’:
md/setjmp64_.c:72:15: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
72 | _longjmp(*(jmp_buf *)&rjb, push_buf((void *)jb));
| ^~~~~~~~~~~~~~~
md/setjmp64_.c: In function ‘qt_block’:
md/setjmp64_.c:109:15: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
109 | _longjmp(*(jmp_buf *)&sp, push_buf((void *)&help));
| ^~~~~~~~~~~~~~
md/setjmp64_.c: In function ‘qt_abort’:
md/setjmp64_.c:123:13: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
123 | _longjmp(*(jmp_buf *)&sp, push_buf((void *)&help));
| ^~~~~~~~~~~~~~
I tried to compile with LTO:
-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
The -Werror=* flags are important to detect cases where the compiler can try to optimize based on assuming UB cannot happen, and miscompile code that has UB in it. strict-aliasing issues are always bad but LTO can make them even worse.
I got this error:
Downstream report: https://bugs.gentoo.org/863725 Full build log: build.log.txt