From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E7CAC385840D for ; Thu, 7 Dec 2023 12:59:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E7CAC385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E7CAC385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701953997; cv=none; b=Nh8uqkGzXdFx9VowLxhid6HLADKnFAS/QjUYnSTzWxQgJJt2IrSwv5ErIiHq4SWWAiL9OiWgoRgKRr7ua6zw0+eVjMyYgSqqMOysU8sI1u9iwnWuiwhXXe1oW81hANNH5ufTJcDFc6f8hXHTl4n1cDWLkZx7/OcrUSMDZLd0wcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701953997; c=relaxed/simple; bh=hIh/1vXs6KCuKyF69/pmzqvXXnAdPydDvfN/8V1/RWo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=WCf8AuUl8txfZoj+opKZnNhgMwkxQP2cuEaz3JsA5rCx4dOkLbEtOAsaljbV0KNn0C0wXj+isbaHYAB6vHK3AGr+fyFWj+qxkGhz9vGmgmM18PapOCKlBZ5eZpxZCWvM7jk5g00ZfTWqv1RCTKpibzP88H/9jQdiEjJnTKxxNL0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701953994; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=g+yaKLyRzAhVggox/qCr8pF48/IGVoWxT2zZjvfjhME=; b=a3ii4mxm8StA1QGzVMotXpvS43EhFZ2Xknabo1mJJ4/LkA7CmnwKFH9qbhUZXvc951cSmm 4h/6So/idFw7SWk14MMJoJytoeso0e3sM6wknMcQBWJOzlRYzf1shP7iwH4QbJV1rPdmZh 29MCTotY6uumUAnduWyqSyxkHHruKcw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668--UpUHn1hNGiBL6zqUuwt6A-1; Thu, 07 Dec 2023 07:59:51 -0500 X-MC-Unique: -UpUHn1hNGiBL6zqUuwt6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33FB41C05AF1; Thu, 7 Dec 2023 12:59:51 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA4AE3C32; Thu, 7 Dec 2023 12:59:50 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3B7Cxm1Q163339 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 7 Dec 2023 13:59:48 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3B7CxlDu163338; Thu, 7 Dec 2023 13:59:47 +0100 Date: Thu, 7 Dec 2023 13:59:46 +0100 From: Jakub Jelinek To: Rainer Orth Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Dec 04, 2023 at 11:42:09AM +0100, Rainer Orth wrote: > The recent warning patches broke the libssp build on Solaris: > > /vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk': > /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit declaration of function 'gets'; did you mean 'getw'? [-Wimplicit-function-declaration] > 67 | return gets (s); > | ^~~~ > | getw > /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion] > 67 | return gets (s); > | ^~~~~~~~ > /vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion] > 74 | return gets (s); > | ^~~~~~~~ > > The guard around the gets declaration in gets-chk.c is > > #if !(!defined __USE_ISOC11 \ > || (defined __cplusplus && __cplusplus <= 201103L)) > extern char *gets (char *); > #endif > > __USE_ISOC11 is a glibc-only thing, while Solaris > declares gets like > > #if __STDC_VERSION__ < 201112L && __cplusplus < 201402L > extern char *gets(char *) __ATTR_DEPRECATED; > #endif > > If one needs to check __USE_ISO11 at all, one certainly needs to check > __STDC_VERSION__ to avoid breaking every non-glibc target. Besides, I > don't see what's the use of checking __cplusplus when compiling a C-only > source file. On top of all that, the double negation makes the guard > unnecessarily hard to understand. > > I really don't know if it's useful/appropriate to check __USE_ISOC11 and > __cplusplus here at all; still I've left both for now. > > Here's what I've used to complete the Solaris bootstrap. > > Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, > x86_64-pc-linux-gnu, and x86_64-apple-darwin23.1.0. > > -- > ----------------------------------------------------------------------------- > Rainer Orth, Center for Biotechnology, Bielefeld University > > > 2023-12-03 Rainer Orth > > libssp: > * gets-chk.c (gets): Avoid double negation. > Also check __STDC_VERSION__ >= 201112L. > > # HG changeset patch > # Parent 334015ab01f6c0e5af821c1e9bc83b8677cc0bfb > libssp: Fix gets-chk.c compilation on Solaris > > diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c > --- a/libssp/gets-chk.c > +++ b/libssp/gets-chk.c > @@ -51,8 +51,9 @@ see the files COPYING3 and COPYING.RUNTI > # include > #endif > > -#if !(!defined __USE_ISOC11 \ > - || (defined __cplusplus && __cplusplus <= 201103L)) > +#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) \ > + || !defined __USE_ISOC11 \ > + || (defined __cplusplus && __cplusplus >= 201402L) The above isn't equivalent. Avoiding double negation would mean #if (defined __USE_ISOC11 \ && !(defined __cplusplus && __cplusplus <= 201103L)) or #if (defined __USE_ISOC11 \ && (!defined __cplusplus || __cplusplus > 201103L)) No? __USE_ISOC11 is defined as /* This is to enable the ISO C11 extension. */ #if (defined _ISOC11_SOURCE || defined _ISOC2X_SOURCE \ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) # define __USE_ISOC11 1 #endif where _ISOC11_SOURCE or _ISOC2X_SOURCE are defined whenever _GNU_SOURCE is or when user defines them, or __USE_ISOC11 is also defined for if __cplusplus >= 201703L. Obviously, if you add that (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) it will mean it will be prototyped always (as I think we compile it without any -std= flags). What about using what we had for glibc (or even better, expect gets to be declared for glibc < 2.16) and use what you add for other libraries? The file is written and compiled as C, so we don't need to bother with C++ though. So #if (defined (__GLIBC_PREREQ) \ ? (__GLIBC_PREREQ (2, 16) && defined (__USE_ISOC11)) \ : (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) ? > extern char *gets (char *); > #endif Jakub