4 ms·
Your problem is that whoever designed that Serial class is incompetent and should be shot and their body defiled in unspeakable ways. The C-language varargs co
by bregma 2y ago
Your problem is that whoever designed that Serial class is incompetent and should be shot and their body defiled in unspeakable ways.
The C-language varargs concept and the C++ object model are not compatible. C++ provides varargs only for backwards compatibility with legacy C libraries. New APIs written in C++ should not be using it because passing a C++ object through it is undefined behaviour. No amount of rationalizing (as all the comments downthread are doing) is of any value: undefined behavior is undefined.
- mmaniac 2y agoYet GCC will still apparently let you call this function without as much as a warning. This should be one of the easiest mistakes to find statically. Clang at least errors out here. C++ is a mess.
- bregma 2y agoWell, if the designer of the class used the right annotations GCC will issue a warning if warnings are enabled. This is third-party code and nothing to do with GCC per se and the language itself does not require any kind of compile-time warning for undefined behaviour. Then again, most people seem to disable or ignore the warnings the toolchain gives them. You can make anything idiot-proof but there's always a bigger idiot. It sounds more like a crappy library designed by people who don't know their craft. It's easier to blame the tools.
- shermantanktop 2y agoIt’s Arduino so it’s C++ through the looking glass. Some unusual choices about core classes and syntactic sugar via a bit of preprocessing, plus the opaque error messages and core dumps we all know and love, but on a tiny device with a serial connection.
- SomeoneFromCA 2y agoIs it even possible to core dump on AVR, with no storage and MMU?
- shermantanktop 2y agoSeg fault, I guess? It’s been a while.
- SomeoneFromCA 2y agoAVR has no protection and no segments. I mean really, it seems to be true that new generation of programmers have zero understanding of hardware, nothing personal.
- shermantanktop 2y agoNothing personal taken. If I was something more than a hobbyist wrt to hardware, then I might. I was having this conversation with someone the other day regarding GenAI. The expectations for understanding the lowest-level concerns have changed generationally. Today's hardware wizard might prize their old-school understanding of fundamentals but would probably be rubbish in 1948.
- saagarjha 2y agoIt is completely legal to pass a C++ object through varargs.