"C" compiler where 0 is not of type int?

Liste des GroupesRevenir à l c 
Sujet : "C" compiler where 0 is not of type int?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 18. Jul 2024, 05:03:39
Autres entêtes
Organisation : None to speak of
Message-ID : <87ikx3h050.fsf@nosuchdomain.example.com>
User-Agent : Gnus/5.13 (Gnus v5.13)
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.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
18 Jul 24 * "C" compiler where 0 is not of type int?4Keith Thompson
18 Jul 24 +* Re: "C" compiler where 0 is not of type int?2Richard Damon
18 Jul 24 i`- Re: "C" compiler where 0 is not of type int?1David Brown
18 Jul 24 `- Re: "C" compiler where 0 is not of type int?1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal