Deutsch English Français Italiano |
<87wmlyt7vj.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: question about nullptr Date: Sat, 06 Jul 2024 16:31:44 -0700 Organization: None to speak of Lines: 29 Message-ID: <87wmlyt7vj.fsf@nosuchdomain.example.com> References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com> <v6bfi1$3qn4u$1@dont-email.me> <l9ciO.7$cr5e.2@fx05.iad> <v6c1su$3tl33$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sun, 07 Jul 2024 01:31:45 +0200 (CEST) Injection-Info: dont-email.me; posting-host="31bef4326a7de5d231f958bc2ab73da5"; logging-data="4185240"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tqnNLapISZRqPZHr+Rezp" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:xCnD8UJi3m5MtA2snpPGAoe7rUE= sha1:2rvL5J4qOyKX7D5cpeOaw56PG5E= Bytes: 2299 bart <bc@freeuk.com> writes: > On 06/07/2024 15:04, Scott Lurndal wrote: [...] >> Whereas I spent 6 years programming on an architecture[*] where a >> null pointer was represented in hardware by the value 0xc0eeeeee. I always >> use the NULL macro in both C and C++ code. > > You can ignore that requirement and just use all-bits-zero (in memory, > not just in C source code). After all, the only thing you might want > hardware support for is trapping a dereference of a NULL value. You write this in response to someone saying they've used a system where a null pointer is *not* all-bits-zero. The vast majority of systems do represent a null pointer as all-bits-zero, and you can usually get away with assuming that. There are even some cases where it might be worthwhile, for example if you need to memset chunks of memory that contain pointers and aren't concerned about 100% portability (or if you're using your own langauge). Or you can use the language in a way that works correctly regardless of now null pointers are represented. That's what I do. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */