Is void *p = 0L valid?

Posted by Artefacto on Stack Overflow See other posts from Stack Overflow or by Artefacto
Published on 2010-12-24T15:39:07Z Indexed on 2010/12/24 15:54 UTC
Read the original article Hit count: 152

Filed under:

In this answer, sassman initializes a pointer with:

zend_class_entry* ce = 0L;

My question is – is this valid? I would say it isn't, to initialize the variable with a null pointer either an unadorned (and possibly casted to void *) 0 constant, or some macro that evaluates to that such as NULL should be used.

However, I can't find definitive language in the standard that supports this interpretation. All it says is:

An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.

© Stack Overflow or respective owner

Related posts about c