Thread View: gnu.g++
1 messages
1 total messages
Started by ken
Fri, 23 Jun 1989 20:39
type of '\0'
Author: ken
Date: Fri, 23 Jun 1989 20:39
Date: Fri, 23 Jun 1989 20:39
21 lines
991 bytes
991 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads