You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #26715 any 8 bit boards that compile in Marlin/src/libs/hex_print.cpp generate this warning
Marlin/src/libs/hex_print.cpp: In function 'char* hex_long(uintptr_t)':
Marlin/src/libs/hex_print.cpp:57:31: warning: right shift count >= width of type [-Wshift-count-overflow]
_hex[2] = hex_nybble(l >> 28);
^~
Marlin/src/libs/hex_print.cpp:58:31: warning: right shift count >= width of type [-Wshift-count-overflow]
_hex[3] = hex_nybble(l >> 24);
^~
Marlin/src/libs/hex_print.cpp:59:31: warning: right shift count >= width of type [-Wshift-count-overflow]
_hex[4] = hex_nybble(l >> 20);
^~
Marlin/src/libs/hex_print.cpp:60:31: warning: right shift count >= width of type [-Wshift-count-overflow]
_hex[5] = hex_nybble(l >> 16);
^~
This used to be in a #ifdef CPU_32_BIT block so 8 bit boards would not look at this function.
But currently the #ifdef block was removed and this function is included for all boards, but uintptr_t is not a independent specific size.
On 8 bit boards typedef uint16_t uintptr_t;
on 32 bit boards typedef unsigned int uintptr_t;
on 64 bit simulator typedef unsigned long int uintptr_t
The function expects 32bits
so on 8 bit boards it is passing a 16bit number and the high 16bits are lost and the warning are generated
Did you test the latest
bugfix-2.1.x
code?Yes, and the problem still exists.
Bug Description
Since #26715 any 8 bit boards that compile in Marlin/src/libs/hex_print.cpp generate this warning
The cause is this function
This used to be in a
#ifdef CPU_32_BIT
block so 8 bit boards would not look at this function.But currently the #ifdef block was removed and this function is included for all boards, but uintptr_t is not a independent specific size.
On 8 bit boards
typedef uint16_t uintptr_t;
on 32 bit boards
typedef unsigned int uintptr_t;
on 64 bit simulator
typedef unsigned long int uintptr_t
The function expects 32bits
so on 8 bit boards it is passing a 16bit number and the high 16bits are lost and the warning are generated
Bug Timeline
since #26715
Expected behavior
No warning, no truncation.
Actual behavior
Warnings and data truncation
Steps to Reproduce
Version of Marlin Firmware
Bugfix-2.1.x
Electronics
RAMPS
POSSABLE fixes
a) put the #if block back around the entire function
b) update uintptr_t to uint32_t
At present this would conflict with the variable size of _hex
c) add a #if CPU_32_BIT around the top 4 bytes so the code becomes
d) (The 'thinkyhead' method) refactor all of marlin to use yet to be created
hex_8bit
hex_16bit
hex_32bit
and forget about the somewhat ambiguous "byte", "word" and "long"
The text was updated successfully, but these errors were encountered: