From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BE86B1F5A0 for ; Mon, 6 Feb 2023 03:27:38 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=fcYG4KCT; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOsAC-0005pP-Sy; Sun, 05 Feb 2023 22:27:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOsAA-0005p9-W1 for bug-gnulib@gnu.org; Sun, 05 Feb 2023 22:27:27 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOsA8-00074Z-Ot for bug-gnulib@gnu.org; Sun, 05 Feb 2023 22:27:26 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1675654039; cv=none; d=strato.com; s=strato-dkim-0002; b=QLVzHBp/57hb2rLUvXh/6jNN6FLSAzUt6mJfqVibwH72y1JnygC6DWjJIbNCJ3Akad qAdQ20zl5dn+K7nIyEcpkN970osJf6INXQEiOmrhFYX0Wzkcfty8AxjfGZouKN267nvH Ui8XeYoVl88i0f7EAEcyCIGeTsykuD4RebNEJg2JIuTAxKSkpjfak2BIGAgALJtnZkF1 vTtZLxZ/ScMxeq2w67n7elB7J5YW5HHKa9DvVtzlo9H5IOgrd2Sm9keaYXYtXvQRmzoq mgk/w0O8551/KVi8EtKr/Wjj3yNZE5jfYkh6d4b3Itjg9OZXaTH8WmYlnJWLnk42P0H6 KXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1675654039; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=fLVwOIvR+5Cq5XzILwVBxQQBGv+onF76hH3ujdA2VyE=; b=OXAXcOKK4/BQbAu+29k3C13MdeNh/ko826an7xvdp3QeesT+v+GLyZtHOh/lJp/nOJ i4jeDayNQ4VRfFl8Sx54epRxsykzd3UAPpIJSwSayF5tG/ZkF4gWVMH2Yop863h7jXLN j+03miRQF/v3Qdf7DLksYbOepElfQ1Hg1kEl2IF+Lgs9PYNWl++9CMcyskVTUP7kqoHX 9BEQbEF5eFc/PRgPfzOdWztOA7QNsJ7A2ANhcB0pDLCONCQ6/dMLPEkhbbpCbLZBMIDZ AIfANffJbHl5zFxjsRt4mhfsZm8ijF01Ap6MlaJUHKh1ND8MV0FQbGxvENqMMfqxIf4W chNw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1675654039; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=fLVwOIvR+5Cq5XzILwVBxQQBGv+onF76hH3ujdA2VyE=; b=fcYG4KCT9dVIga6bZGuvv4h/dFGZ3I1iC2Ma01bb0Zbyghbbz0r+abcJgPX5oqcME2 V0OJMLG1YaO75rI4loseYd0o7IESPNWHGIiht5zrfCjsxF1fuP1RHTWW5OiQUZT9nLub ui8E5kt81OtJ8ID8u+qhFjUjfwVznbtsE0787RWFqkejyqZ1x8IO8oCxa4qc+Hd+c7QW +nPL9DlRk/keV/F8ECc4rmO2T4OHEMkelg6ou9h6igeNY85+ycOhjgNri/puryZlp11U XxC75jJh0TBBzzNz8JzGsjmfYl0FpLif0ISqFy0x5sAEZD8XM+7mmQ+mcYOJQu85RAd9 29nw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPF1PD+ezUIF+ECAUv0KY3UBImwtw==" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z163RI6u6 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 6 Feb 2023 04:27:18 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Cc: Bjarni Ingi Gislason Subject: Re: module c-nullptr: error compiling groff Date: Mon, 06 Feb 2023 04:27:18 +0100 Message-ID: <6051252.riuWyFgYyT@nimes> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.161; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Bjarni Ingi Gislason wrote: > Debian testing (bookworm/sid) > > gcc (Debian 12.2.0-14) 12.2.0 > > GNU Make 4.4.0.90 > > > [...] > CXX src/roff/troff/env.o > In file included from /usr/include/c++/12/bits/stl_bvector.h:61, > from /usr/include/c++/12/vector:65, > from ../src/roff/troff/charinfo.h:20, > from ../src/roff/troff/env.cpp:31: > /usr/include/c++/12/bits/functional_hash.h:273:12: error: redefinition of 'struct std::hash' > 273 | struct hash : public __hash_base > | ^~~~~~~~~~~~~~~ > /usr/include/c++/12/bits/functional_hash.h:157:3: note: previous definition of 'struct std::hash' > 157 | _Cxx_hashtable_define_trivial_hash(long) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > make[1]: *** [Makefile:10126: src/roff/troff/env.o] Error 1 Thanks for the report. I reproduce it with the just-added unit tests, with GCC 11 or 12, but not with other compilers (GCC 10 or older, clang, MSVC, AIX xlc, Solaris cc). But even when there is no error in the unit test, there could be errors in application code, if we define nullptr to some value that is inferior to what the C++ compiler already does. So, the guideline should be: If the C++ compiler already supports 'nullptr', leave it alone and don't define it as a macro. I found out that for g++ and clang++, 'nullptr' is supported with the options -std=c++11, -std=c++14, -std=c++17 and not supported with the option -std=c++03. To detect this situation, the value of __cplusplus can be used. The various __cpp_* macros don't help here. Also, MSVC 14 supports it, although its __cplusplus value is only 199711L. In my tests, AIX xlc and Solaris cc (up to Developer Studio 12.6) don't support it. Taken together, this gives this fix. 2023-02-05 Bruno Haible c-nullptr: Fix conflict with libstdc++ in GCC >= 11. Reported by Bjarni Ingi Gislason in . * m4/c-nullptr.m4 (gl_C_NULLPTR): Don't define nullptr if it is already defined. In C++ mode, ignore the result of the configure test and don't define it when we know that the C++ compiler already supports it. diff --git a/m4/c-nullptr.m4 b/m4/c-nullptr.m4 index af79854696..960eeff18d 100644 --- a/m4/c-nullptr.m4 +++ b/m4/c-nullptr.m4 @@ -18,13 +18,25 @@ AC_DEFUN([gl_C_NULLPTR], ]) AH_VERBATIM([nullptr], -[#ifndef HAVE_C_NULLPTR -# ifndef __cplusplus -# define nullptr ((void *) 0) -# elif 3 <= __GNUG__ -# define nullptr __null +[#ifndef nullptr /* keep config.h idempotent */ +# ifdef __cplusplus +/* For the C++ compiler the result of the configure test is irrelevant. + We know that at least g++ and clang with option -std=c++11 or higher, as well + as MSVC 14 or newer, already have nullptr. */ +# if !(((defined __GNUC__ || defined __clang__) && __cplusplus >= 201103L) \ + || (defined _MSC_VER && 1900 <= _MSC_VER)) +/* Define nullptr as a macro, the best we can. */ +# if 3 <= __GNUG__ +# define nullptr __null +# else +# define nullptr 0L +# endif +# endif # else -# define nullptr 0L +/* For the C compiler, use the result of the configure test. */ +# ifndef HAVE_C_NULLPTR +# define nullptr ((void *) 0) +# endif # endif #endif]) ])