Yet 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.
Well, 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.
Re:Panic at the Job Market
by shermantanktop on Thursday July 18, 2024 @10:50AM
(#40996116)
It’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.
Re:Panic at the Job Market
by SomeoneFromCA on Thursday July 18, 2024 @03:59PM
(#40999155)
Is it even possible to core dump on AVR, with no storage and MMU?
Re:Panic at the Job Market
by shermantanktop on Friday July 19, 2024 @12:02AM
(#41001932)
Seg fault, I guess? It’s been a while.
Re:Panic at the Job Market
by SomeoneFromCA on Friday July 19, 2024 @05:28AM
(#41004096)
AVR 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.
Re:Panic at the Job Market
by shermantanktop on Friday July 19, 2024 @02:30PM
(#41009567)
Nothing 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.
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.