From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 24D6A20248 for ; Fri, 22 Mar 2019 16:05:39 +0000 (UTC) Received: from localhost ([127.0.0.1]:59653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7Mfm-0004Te-3I for normalperson@yhbt.net; Fri, 22 Mar 2019 12:05:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7MbD-0000WL-8L for bug-gnulib@gnu.org; Fri, 22 Mar 2019 12:00:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7MbB-0005g7-Mw for bug-gnulib@gnu.org; Fri, 22 Mar 2019 12:00:51 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:45083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7MbB-0005R3-8Y for bug-gnulib@gnu.org; Fri, 22 Mar 2019 12:00:49 -0400 Received: by mail-wr1-x436.google.com with SMTP id s15so2903810wra.12 for ; Fri, 22 Mar 2019 09:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9Km+jwauO/l75laABFSbLephGLuSjR2MLJhBIDGrDw=; b=ArsmX0Z5A9NPmPdo3Prc9I6pUyZGSyGLl952H3T9GG0DLOO9N1n8GJhSk8RU++A1aA QCW7Ta8DOrnqgs+P6Capymm+lSm+W5W8BSvufqAWisSK0Nbz+ELhZF75K3SYKRIRr+em FX7VI3aDsLRIkBBFJ1MEZDBVqM4rKewzitmyaei2oxl0TnWjE2hogUJqYylW4M0O9obM CIBidvm4V3i+MyKWOVlsnS1i9w0a+zfENv28dCjLoorgUCf5BCm11k+e4GzdMckwIGl4 /ep+pzo1lpg15inMRxXuEnkfXew8RvsIRTWjpIBj7/2Y1iN1TzxPjWccTZECU0dTSA7r s+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9Km+jwauO/l75laABFSbLephGLuSjR2MLJhBIDGrDw=; b=oVR791j4EravbAdlVu1AFQe9LZPtUUnhDilaHFzElJn5PAd3HepsMWfmu9lZu5xXOJ HjJcPgyDu6k7epVg624pfY5f/Ay6WEUkhAPTe8zYGyE30ae9ykT8KOz8UEbvEbmTHGPu esSGcDAEGiXofAJxfcsb4XYUypNP82JRass/dvwQWaMfe2p2uFkI4nzdHxX5XufRXw/h CNVMAAcpctg+vlPhmR52NmtW+UaOpt0hYndneq9+4OP1vpvfmwYZ+4oYSWqllh70llvl K2JS7lU6qFvBOsnFOjTC0E7kNA4ZjvM3wnkwJsTVyX8dtj9fH2WPGpD1L1nEir1ZAZfi efng== X-Gm-Message-State: APjAAAWKad35C8wHgRt18HPypl9z/fPn3fwL3Sfb+/D+rExqop7qCwic cfRW3Z6xqXN2gYCd4fnWjMY= X-Google-Smtp-Source: APXvYqzLcu2XgD+hzumJ0CtrsbKzr+SLE+X0bRB7Y0DRU0n9JG585OwTHuRJGvUU2DgJQ3DI/4lszQ== X-Received: by 2002:a5d:4f89:: with SMTP id d9mr5349970wru.195.1553270446114; Fri, 22 Mar 2019 09:00:46 -0700 (PDT) Received: from [172.20.10.14] ([37.169.89.133]) by smtp.gmail.com with ESMTPSA id b4sm9480657wmj.3.2019.03.22.09.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 09:00:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: undefined behaviour findings in bitset From: Akim Demaille In-Reply-To: <334DD9B5-B8E4-4A48-BBAA-9677F912FFF2@lrde.epita.fr> Date: Fri, 22 Mar 2019 17:00:43 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1931657.LsgtlLSD0p@omega> <2593862.vejflyQVVE@omega> <01823B93-67BA-48A1-894E-92B3AC639E75@lrde.epita.fr> <2408981.H5WmhMbU37@omega> <334DD9B5-B8E4-4A48-BBAA-9677F912FFF2@lrde.epita.fr> To: Bruno Haible X-Mailer: Apple Mail (2.3445.102.3) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Bruno, > Le 19 mars 2019 =C3=A0 07:07, Akim Demaille a = =C3=A9crit : >=20 > Hi Bruno, >=20 >> Le 18 mars 2019 =C3=A0 22:03, Bruno Haible a =C3=A9cr= it : >>=20 >> Hi Akim, >>=20 >>> Also, the relationship with noreturn.h is not completely clear for >>> me either. >>=20 >> There are a couple of comment in noreturn.h lines 33..41. But I = agree, >> some text in the documentation would be better. >>=20 >>> Clang 7 pretends to be GCC 4.2 (__GNUC__ __GNUC_MINOR__). >>=20 >>> For instance I see it already has the above fix for >>> GCC 4.7, but in a different way. >>>=20 >>> /* Use ISO C++11 syntax when the compiler supports it. */ >>> # if (__cplusplus >=3D 201103 && !(__GNUC__ =3D=3D 4 && = __GNUC_MINOR__ =3D=3D 7)) \ >>> || (_MSC_VER >=3D 1900) >>> # define _GL_NORETURN_FUNC [[noreturn]] >>=20 >> Right, this snippet gets clang++ and MSVC++ support right. How about = this >> patch? >=20 > Yes, I agree this is the best option so far, thanks! Well, it does not work with G++ in C++98 mode: _Noreturn is not = supported there. This works with Bison's CI: commit b2a7dec46c0b702b5f7618994641e7381c8ff86f Author: Akim Demaille Date: Fri Mar 22 08:25:53 2019 +0100 _Noreturn: beware of C's _Noreturn in C++ pre C++11 * lib/_Noreturn.h, m4/gnulib-common.m4: Using C's _Noreturn in C++98 appears to be supported by Clang, but not by GCC nor ICC. diff --git a/ChangeLog b/ChangeLog index 62c522e65..b694c3512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-03-22 Akim Demaille + + _Noreturn: beware of C's _Noreturn in C++ pre C++11. + * lib/_Noreturn.h, m4/gnulib-common.m4: Using C's _Noreturn in + C++98 appears to be supported by Clang, but not by GCC nor ICC. + 2019-03-19 Akim Demaille bitset: fix memory leaks diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index 1629cef39..7594e4b0c 100644 --- a/lib/_Noreturn.h +++ b/lib/_Noreturn.h @@ -3,8 +3,9 @@ && ((201103 <=3D __cplusplus && !(__GNUC__ =3D=3D 4 && = __GNUC_MINOR__ =3D=3D 7)) \ || (defined _MSC_VER && 1900 <=3D _MSC_VER))) # define _Noreturn [[noreturn]] -# elif (201112 <=3D (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <=3D __GNUC_MINOR__)) +# elif ((!defined __cplusplus || defined __clang__) = \ + && (201112 <=3D (defined __STDC_VERSION__ ? __STDC_VERSION__ : = 0) \ + || 4 < __GNUC__ + (7 <=3D __GNUC_MINOR__))) /* _Noreturn works as-is. */ # elif 2 < __GNUC__ + (8 <=3D __GNUC_MINOR__) || 0x5110 <=3D __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__)) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 8ad963e35..57b94ed53 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -21,8 +21,9 @@ AC_DEFUN([gl_COMMON_BODY], [ && ((201103 <=3D __cplusplus && !(__GNUC__ =3D=3D 4 && = __GNUC_MINOR__ =3D=3D 7)) \ || (defined _MSC_VER && 1900 <=3D _MSC_VER))) # define _Noreturn [[noreturn]] -# elif (201112 <=3D (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <=3D __GNUC_MINOR__)) +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <=3D (defined __STDC_VERSION__ ? __STDC_VERSION__ : = 0) \ + || 4 < __GNUC__ + (7 <=3D __GNUC_MINOR__))) /* _Noreturn works as-is. */ # elif 2 < __GNUC__ + (8 <=3D __GNUC_MINOR__) || 0x5110 <=3D __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__))