Keith Thompson
2024-07-18 03:03:39 UTC
This is going to sound like an odd question, because it is.
I saw this code fragment in an answer posted on Quora:
// In case literal 0 isn't an int on this platform.
int z = (int) 0;
The writer encountered this in an old C project, and suggested that the
author of the code might have had a legitimate concern. (He ended up
removing the cast.)
Obviously 0 is of type int in every C standard. If the cast were
necessary, it would be because of a non-conforming compiler.
I've heard of non-conforming C compilers that make int 8 bits, or that
don't have long double, or that have a long double type that doesn't
meet the standard's range and/or precision requirements.
My question is this: Has there ever been a (non-conforming) C compiler
that gave a constant 0 a type other than int?
(I'm ignoring the use of a "//" comment; the writer may not have copied
the code verbatim.)
I saw this code fragment in an answer posted on Quora:
// In case literal 0 isn't an int on this platform.
int z = (int) 0;
The writer encountered this in an old C project, and suggested that the
author of the code might have had a legitimate concern. (He ended up
removing the cast.)
Obviously 0 is of type int in every C standard. If the cast were
necessary, it would be because of a non-conforming compiler.
I've heard of non-conforming C compilers that make int 8 bits, or that
don't have long double, or that have a long double type that doesn't
meet the standard's range and/or precision requirements.
My question is this: Has there ever been a (non-conforming) C compiler
that gave a constant 0 a type other than int?
(I'm ignoring the use of a "//" comment; the writer may not have copied
the code verbatim.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+***@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Keith Thompson (The_Other_Keith) Keith.S.Thompson+***@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */