From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S267306AbUGNDMj (ORCPT ); Tue, 13 Jul 2004 23:12:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S267310AbUGNDMj (ORCPT ); Tue, 13 Jul 2004 23:12:39 -0400 Received: from mx1.redhat.com ([66.187.233.31]:34728 "EHLO mx1.redhat.com") by vger.kernel.org with ESMTP id S267306AbUGNDMf (ORCPT ); Tue, 13 Jul 2004 23:12:35 -0400 To: Geert Uytterhoeven Cc: Olaf Titz , Linux Kernel Development Subject: Re: [PATCH] Use NULL instead of integer 0 in security/selinux/ References: From: Alexandre Oliva Organization: Red Hat Global Engineering Services Compiler Team Date: 14 Jul 2004 00:12:22 -0300 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Jul 13, 2004, Geert Uytterhoeven wrote: > On Sun, 11 Jul 2004, Olaf Titz wrote: >> in C. (Worse in C++ where usage of NULL is discouraged, I've always >> wondered about the reasons.) > [ wondered about this as well, but the answer has been posted before in this > thread ] > Because C++ doesn't do implicit conversions from void * to anything *. So what? NULL must have an integral type in C++. void* is explicitly forbidding in the C++ Standard. I don't see that NULL is discouraged in C++. It's mostly redundant, like it is in C, and it's not safe for varargs even on machines where NULL pointers are represented can be zero-initialized, because pointers to members and regular pointers don't even have the same size, unlike C, that doesn't have pointers to members and thus can safely use (intptr_t)0 for NULL and it will even work for varargs (given the considerations above). -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}