-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HardwareSerial::write(long/int) is incorrect/dangerous! #55
Comments
Took me a bit of searching (your bug reports are a bit concise), but I found the code here: The Print class only defines write(uint8_t), but for some reason HardwareSerial also defines write for other types. I'm not so sure why this is needed - I think the compiler will handle type conversion automatically in this case. In any case, you're misunderstanding the purpose of |
Thx for your answer. I'll try to be a more verbose in the future. I also fixed the subject of this report with the correct class name. I fully understand the semantics of write() & print(). The problem here is, that the "long/int" versions of print versions are not just plain wrong but also very hard to find/debug why the numbers are "cut-off". (it' didn't happend to me - just found them by coincidence). Without those overloaded methods, the compiler will give you at least a warning about the "downcast" (or is it an error?). But with those overladed members, everthing seems to work on compile time. |
@sandeepmistry, I'm not sure this really belongs in API. AFAICT from the comments, the Print class is ok, it is just the AVR HardwareSerial class that adds these possibly problematic (and at least unneeded, I think) overloads (maybe other cores too, I did not check). |
any value above 255 will just be cut off -
please remove or fix the incorrect implementations!
The text was updated successfully, but these errors were encountered: