All the weird stuff I have read about C or C++ doing over the years could be summed up with “Well… don’t do that.”
Like almost without fail. I can’t even think of how you’d end up in a scenario like this because a compiler would complain before letting you use an undefined implicit declaration.
Most people build C in g++ before gcc, as it tends to have a better chance of catching most oddities. Then run it past valgrind to double check if something looks suspect or is slowly leaking. =3
I’m not going to defend all of the ones C(++) has but stuff like deref’ing null or integer overflow or out of bounds access has its roots in sanity, it just looks insane today. There are tools for many/most of these and if you’re not using them you’re doing it wrong.
I just rebuilt a core program that talks to my UNIVAC OS2200 CITA and my VAX ACMS from Linux.
I built this first as a 32-bit binary, and there was noise that I had to cut with a substr function.
In the rebuilding with my MinGW 64-bit Windows cross compiler on Oracle Linux, I had to mine function prototypes out of all the code for exactly this reason.
'for those unaware: c89 has a cool "feature" where, if you try to call a function which doesn't exist, rather than erroring out, the function is implicitly declared as a function with unspecified parameters returning int.'
I'm not testing this, because that is agony.
I'm leaving them a working build, and retiring this month.
This code was written by the living and the dead, and my stewardship is finished. I do not envy the poor soul who must test this.
It was ashes when I excavated it myself. A hat tip to those who have gone before.
I have a 30 page document of errors and ambiguities in the C89 standard -- I joined X3J11 with the intention to present it as a "Monday paper" (papers from committee members submitted on the first meeting day) but I couldn't get a flight and didn't arrive until Tuesday, and they (PJ Plauger specifically) wouldn't accept the paper.
At the next meeting I nevertheless voted to accept the standard. (Being first in alphabetical order, I was the first person to ever do so.)
I'm not sure what the "which will never be fixed" part in the title is about, the problem was clearly fixed in C99 by removing the entire "misfeature" from the standard (e.g. GCC and Clang do error out both in C and C++ compilation mode).
My guess is that the implicit declaration was a leftover from a C predecessor (B?) and kept in C to simplify programming in hybrid B/C environments. Just a guess though.
14 comments
[ 3.3 ms ] story [ 42.7 ms ] threadObsolete standard turns out to be insufficiently strict, news at 11.
Like almost without fail. I can’t even think of how you’d end up in a scenario like this because a compiler would complain before letting you use an undefined implicit declaration.
I’m not going to defend all of the ones C(++) has but stuff like deref’ing null or integer overflow or out of bounds access has its roots in sanity, it just looks insane today. There are tools for many/most of these and if you’re not using them you’re doing it wrong.
That's a nice bit of understated 90s design right there
The "nice" sites didn't style much at all, which usually meant the default serif font was used.
It is illegal to perform pointer arithmetic on function pointers. They are not necessarily interchangeable with data pointers. Clang is wrong.
I built this first as a 32-bit binary, and there was noise that I had to cut with a substr function.
In the rebuilding with my MinGW 64-bit Windows cross compiler on Oracle Linux, I had to mine function prototypes out of all the code for exactly this reason.
'for those unaware: c89 has a cool "feature" where, if you try to call a function which doesn't exist, rather than erroring out, the function is implicitly declared as a function with unspecified parameters returning int.'
I'm not testing this, because that is agony.
I'm leaving them a working build, and retiring this month.
This code was written by the living and the dead, and my stewardship is finished. I do not envy the poor soul who must test this.
It was ashes when I excavated it myself. A hat tip to those who have gone before.
At the next meeting I nevertheless voted to accept the standard. (Being first in alphabetical order, I was the first person to ever do so.)
My guess is that the implicit declaration was a leftover from a C predecessor (B?) and kept in C to simplify programming in hybrid B/C environments. Just a guess though.