Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: What is the data structure of a NULL? Date: Tue, 31 Dec 2019 11:20:46 -0800 Organization: None to speak of Lines: 32 Message-ID: <875zhwpai9.fsf@nosuchdomain.example.com> References: <87sgl4rc3w.fsf@nosuchdomain.example.com> <87o8vsqh5l.fsf@nosuchdomain.example.com> <87k16fr9za.fsf@nosuchdomain.example.com> <91dfd68d-0094-4edf-bef1-31bf55b24aa1@googlegroups.com> <9ebdefe5-d01e-4c70-af22-4dc6145b5ba3@googlegroups.com> <66LOF.272786$Ol2.118229@fx22.am4> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="94fc4d7fa52f8ea4ccffaf50350c18bf"; logging-data="32520"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189vjWfhvUw0418/BHLfHob" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:A+PUZ9sMkLlPn4ATSqyEd6PRG+8= sha1:pwVN4XjYuSooUOQxrJPWWB+IJ6M= Xref: csiph.com comp.lang.c++:70904 David Brown writes: [...] > It might compile - "NULL" can be defined as "#define NULL 0" rather > than, say, "((void*) 0)". > > It is not in any way dependent on the representation of null pointers, > as you probably know. In C, NULL can be defined as 0 or as ((void*)0). In C++, ((void*)0) is not a valid definition of NULL, because C++'s definition of "null pointer constant" is more strict than C's. A *null pointer constant* is an integer literal with value zero or a prvalue of type std::nullptr_t. A null pointer constant can be converted to a pointer type; the result is the *null pointer value* of that type and is distinguishable from every other value of object pointer or function pointer type. (In C++11 and earlier, a integral constant expression with value 0 could be a null pointer constant, but C++14 restricted this to integer literals. ((void*)0) hasn't been a valid C++ null pointer constant going back at least to C++98.) But yes, NULL might be usable in a context that requires an integer value depending on how the implementation defines it. Of course it would be silly to depend on that. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */