The old version triggers a stringop-truncation compiler warning. According to the GCC manual, memcpy is the suggested fix in this exact scenario.
Curious: the warning seems to be only triggered in esp-idf's CONFIG_COMPILER_OPTIMIZATION_PERF mode (which corresponds to GCC's -O2 flag). It seems that GCC triggers the warning for -O2, but not for -O1 (demo).
The old version triggers a
stringop-truncation
compiler warning. According to the GCC manual,memcpy
is the suggested fix in this exact scenario.Curious: the warning seems to be only triggered in esp-idf's
CONFIG_COMPILER_OPTIMIZATION_PERF
mode (which corresponds to GCC's-O2
flag). It seems that GCC triggers the warning for-O2
, but not for-O1
(demo).