random C/C++ question: is there any way to implement the chunking optimization w/o violating strict aliasing?https://github.com/esmil/musl/blob/master/src/string/memcpy.c …
@johnregehr IIUC, if the thing is an "allocated object" then it can be accessed willy-nilly as the lvalue type is the effective type.
-
-
@johnregehr But, it does seem to mean that using this optimization on anything allocated as `static` or `auto` would be UB. Hard to read. -
@BRIAN_____ hmm, I can't believe that malloced memory is exempt from strict aliasing-- this would defeat almost 100% of the perf benefit -
@johnregehr The rules for converting pointers to different types are also relevant, AFAICT. -
@johnregehr Never mind, I think I'm wrong. I think, indeed, you cannot do the chunking optimization in strict ISO C, in general. -
@BRIAN_____ are you reading C99 or C11? does C++ differ meaningfully here? -
@johnregehr I am reading n1548.pdf. -
@BRIAN_____@johnregehr n1570.pdf is newer.
End of conversation
New conversation -
-
-
@BRIAN_____@johnregehr If you stored something into allocated mem via type other than char than it becomes its effective type for reading. -
@ch3root@johnregehr Only for "object having no declared type"; i.e. objects allocated using malloc/alloca/etc. -
@BRIAN_____@johnregehr Yes, I used "allocated" to refer to storage duration (as opposed to static, thread and automatic). C11, 6.2.4p1.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.