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
c is int with an unsigned value 0xCA. t->str is const char * with (on Arduino Mega 2560 R3) a signed value -54 decimal which as an unsigned value is 0xCA.
In the comparison, the char is sign extended to an int, resulting in 0xFFFFFFCA giving:
if (0xCA == 0xFFFFFFCA) {
This is never true and not the intention. There appear to be other comparisons in Stream.cpp with this problem.
The text was updated successfully, but these errors were encountered:
This code hangs forever, even when Serial repeatedly receives 0xCA, tested on Arduino Mega 2560 R3:
The reason is in Stream
findMulti
:https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Stream.cpp#L270
Consider this comparison:
c
isint
with an unsigned value 0xCA.t->str
isconst char *
with (on Arduino Mega 2560 R3) a signed value -54 decimal which as an unsigned value is 0xCA.In the comparison, the char is sign extended to an int, resulting in 0xFFFFFFCA giving:
This is never true and not the intention. There appear to be other comparisons in Stream.cpp with this problem.
The text was updated successfully, but these errors were encountered: