Closed henrygab closed 3 years ago
EXPANDABLE .. but collapsed so thread doesn't get too long.
Therefore, it's very important to have a correct fix, not just hide this warning.
Next steps might be to look into:
std::is_trivially_copyable<typeof(DmacDescriptor)>::value
Presuming this is false, why is it false, and what can be done to ensure only defined compiler behavior is used?
ok do you have a PR fix suggestion?
Not yet, but I plan to.
@ladyada -- PR is ready. Explanation of root cause and why the fix is correct in prior comment. Hope that helps! 👍
FAILING TO FIX THIS RESULTS IN WARNINGS OF POTENTIAL UNDEFINED BEHAVIOR.
This should not be worked around by casting to
void*
.~The open question: What causes
DmacDescriptor
to not be considered trivially copyable?~GCC warning of undefined behavior
``` ...\libraries\SPI\SPI.cpp: In member function 'void SPIClass::dmaAllocate()': ...\libraries\SPI\SPI.cpp: Line 338 Char 37 warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct DmacDescriptor' with no trivial copy-assignment [-Wclass-memaccess] 338 | sizeof(DmacDescriptor)); | ^ ...\libraries\SPI\SPI.cpp: Line 342 Char 37 warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct DmacDescriptor' with no trivial copy-assignment [-Wclass-memaccess] 342 | sizeof(DmacDescriptor)); | ^ In file included from ...\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:253, from ...\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69, from ...\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105, from ...\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540, from ...\cores\arduino/Arduino.h:48, from ...\libraries\SPI\SPI.h:23, from ...\libraries\SPI\SPI.cpp:20: ...\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/component/dmac.h:1070:16: note: 'struct DmacDescriptor' declared here 1070 | typedef struct { | ^ ```