Re: segfault on strtok

From: pete (pfiland_at_mindspring.com)
Date: 10/24/03


Date: Fri, 24 Oct 2003 12:51:17 GMT

Andreas Kahari wrote:
>
> In article <3F9912C6.1399@mindspring.com>, pete wrote:
> > Andreas Kahari wrote:
> >
> >> Yes, the integer zero is a null pointer, but only if it's cast
> >> to void * and converted into a pointer type.
> >
> > A constant expression with a value of zero,
> > is called a "null pointer constant"
> > (you can find that phrase in the standard),
> > whther or not it's cast to (void*).
>
> I was looking at the standard when I wrote it. It says that an
> integer which is zero is a null pointer constant if cast to void *.
> That null pointer constant is a null pointer if converted to
> a pointer type.

I read it differently from the way that you do.

N869
6.3.2.3 Pointers
[#3]
An integer constant expression with the value 0,
or such an expression cast to type void *,
is called a null pointer constant.

-- 
pete


Relevant Pages

  • Re: segfault on strtok
    ... >>A constant expression with a value of zero, ... > I was looking at the standard when I wrote it. ... > integer which is zero is a null pointer constant if cast to void *. ...
    (comp.lang.c)
  • Re: What is the type of 1 ? 0L : (long long *)0
    ... it should have arithmetic type not pointer type. ... The fact that 0L is an arithmetic constant expression does not ... it qualifies as a null pointer constant. ...
    (comp.lang.c)
  • Re: Compiler error or? Microsoft VC++ v6.0
    ... The rule says that a null pointer constant is a ... > constant expression evaluating to zero. ... > constant qualifies as a constant expression. ...
    (microsoft.public.vc.language)
  • Re: Compiler error or? Microsoft VC++ v6.0
    ... The rule says that a null pointer constant is a ... >> constant expression evaluating to zero. ... >> constant qualifies as a constant expression. ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.language)
  • Re: offsetof() macro
    ... (If I were designing the language from scratch, ... Using 0 in a pointer context would be a constraint error. ... have said "An integer constant 0 is a valid null pointer constant. ... And also the standard says that a constant expression ...
    (comp.lang.c)