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 19D5D3858D32 for ; Tue, 13 Jun 2023 06:28:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19D5D3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686637712; 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=M39PvtutCLt6zT6Qj7kRY5F9jWZ56ZEBYgW8LXfrPQU=; b=Rg5r5N3uHR0Wo0NUvTFmory7aamg1gQZL5i3X+R5pqEf5VOCPcCM4GmrQbbLb+2uhbMbOg XYtnaxTBr5FUi0hY4qOXqWJtEjRp/PcYYNoyqDEQw0B951EHVkj1C5/qC62aazE6rJxowc k0AlR8Ejp/6KDf7Za3DIrHo2QOm5aFI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-euPJU_MHOXCsmh9HS5o5FA-1; Tue, 13 Jun 2023 02:28:27 -0400 X-MC-Unique: euPJU_MHOXCsmh9HS5o5FA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2668C1C07252; Tue, 13 Jun 2023 06:28:27 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE747C1604D; Tue, 13 Jun 2023 06:28:26 +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 35D6SNP92491806 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 08:28:24 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 35D6SMDi2491805; Tue, 13 Jun 2023 08:28:22 +0200 Date: Tue, 13 Jun 2023 08:28:22 +0200 From: Jakub Jelinek To: Joseph Myers Cc: Marek Polacek , gcc-patches@gcc.gnu.org, libc-alpha@sourceware.org Subject: Re: [RFC] Add stdckdint.h header for C23 Message-ID: Reply-To: Jakub Jelinek References: <68578b43-939-1879-9676-2ea55249a2c5@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <68578b43-939-1879-9676-2ea55249a2c5@codesourcery.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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, Jun 12, 2023 at 09:51:02PM +0000, Joseph Myers wrote: > On Sat, 10 Jun 2023, Jakub Jelinek via Gcc-patches wrote: > > > I have looked at gnulib stdckdint.h and they are full of workarounds > > for various compilers, EDG doesn't do this, clang <= 14 can't multiply > > __int128, ..., so I think the header belongs into the compiler rather > > than C library, because it would be a nightmare to maintain it there. > > While C2x only has type-generic macros in this header, there's a proposal > N2868 (which didn't get consensus for C2x but may come back for a future > standard version) for additional interfaces for structure types with a > sticky overflow flag, including some functions that are expected to be > defined with external linkage as usual for library functions. So if that > gets adopted in future, we'd need to arrange to provide those library > functions with external linkage - which is mostly not something we do in > GCC, although there are a few atomic_* functions in libatomic in addition > to the __atomic_* functions underlying type-generic macros. There is always the possibility to have the header co-owned by both the compiler and C library, limits.h style. Just #if __has_include_next() # include_next #endif perhaps guarded with some macro at the end of the GCC version and do the same at the start of the glibc version again perhaps with some macro. And leave the compiler specific part to the compiler (perhaps with some fallback in the libc version if the compiler specific part is missing) and have the library related part be provided by the C library? But if you want it solely in glibc, I can withdraw my patch (though, perhaps the 2 preparation patches, __typeof_unqual__ and __builtin_classify_type (typeof (...)) could be still of help for it). > > What I'm struggling with is enforcing the weird restrictions > > C23 imposes on these. > > It's not clear all those restrictions need to be enforced - this > definitely seems like a case of undefined behavior to provide useful > extension space, where for various of those restrictions there are unique > sensible semantics to provide if the types in question are supported. So why does C2X say Recommended practice It is recommended to produce a diagnostic message if type2 or type3 are not suitable integer types, or if *result is not a modifiable lvalue of a suitable integer type. ? Or is it meant that a suitable integer type doesn't need to be necessarily one that is listed in the previous paragraph? Perhaps the checking could be guarded on #ifdef __STRICT_ANSI__, sure... Jakub