Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.ROCHESTER.EDU!ken From: ken@CS.ROCHESTER.EDU Newsgroups: gnu.g++ Subject: type of '\0' Message-ID: <8906232039.AA12649@cursa.cs.rochester.edu> Date: 23 Jun 89 20:39:27 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 21 I've just been bitten by the failure of cc, gcc and g++ to detect this kind of error. main() { char *p = 0; if (p == '\0') printf("hmm...\n"); if (p == '\001') printf("hmm...\n"); } Obvious once you see it isn't it? But none of the compilers complained about the first comparison, only the second one. Now, I know about the ANSI rules for nil pointers and I know there are no constants of type char, so '\0' is identical to 0. What I'm asking is, could compilers be not so eager to promote '\0' to type int until the constant is used? The hooks must be there, because g++ has the -fchar-charconst flag.