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: Mon, 30 Dec 2019 10:45:22 -0800 Organization: None to speak of Lines: 41 Message-ID: <87imlxps8t.fsf@nosuchdomain.example.com> References: <87sgl4rc3w.fsf@nosuchdomain.example.com> <87o8vsqh5l.fsf@nosuchdomain.example.com> <87k16fr9za.fsf@nosuchdomain.example.com> <87r20mpaxz.fsf@nosuchdomain.example.com> <878smtr85j.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="0288a230ee44bf2819ced9a20d12e663"; logging-data="18466"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WsTvApi9DVQ18J8BiwaDq" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:hEZSWqMFwbWaR4TS7ArOC4fYKgo= sha1:cr1X9MapiuTcxdH2GzwwXvW8910= Xref: csiph.com comp.lang.c++:70835 Ben Bacarisse writes: > Ned Latham writes: [...] >> Those are design decisions too, idiot. The C++ library throws exceptions. >> Exceptions are evil, especially in low-level code. >> >> And BTW, it's calloc() > > You assume that null pointers are represented with all-bits-zero because > you want to use calloc, and you want to use calloc because you think new > will throw an exception. (If you know about non-throwing new then I > can't see any reason for not using it, thereby allowing null pointers to > dealt with by a constructor as C++ intended.) Is that the whole point of showing us that code, that it depends on a null pointer being represented as all-bits-zero because it uses calloc()? I wonder why Ned didn't just say so rather than sending us on a wild goose chase digging through some online code. I'll probably never know, because I won't waste my time talking to someone who calls people idiots. I can imagine that kind of thing not being entirely a bad idea in code that's not intended to be portable. Using memset or calloc while assuming that null pointers (and floating-point zeros, if applicable) are represented as all-bits-zero is strictly not portable, but it's likely good enough for target-specific code. I'd still try to avoid that assumption unless I had a pretty good reason to depend on it, and I'd be more likely to do something like that in C than in C++. If I wanted to initialize a structure to zeros, I'd rather use a { 0 } initializer than anything that depends on representation. I suspect Ned will take this as proof that I agree with him. For the record, I don't. -- 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 */