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.129.124]) by sourceware.org (Postfix) with ESMTPS id 620A63858D33 for ; Thu, 27 Apr 2023 11:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 620A63858D33 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=1682594196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3D/hYRhp8Otpi6hVzZCAWMy7+urRziks6np1p80pOa4=; b=Cwofnaxts/XafanrW2JqR3IEeI/KFJY/f6ugeUVmmJF4g5t4E2JgWnYY9ikCGsJ9sZ5jK1 JeMPBemkTD4f4EiDzmxO5Z/uPVY7XvQGe4+q3mgOnD709+7mK3EWJtkGhWFsnsRcgtqkkP Jfwd5oaFSbBeyl5ZfPnaJBwUvtZLlVM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-dDiRwWslO2eJ1Q0kVbVO8Q-1; Thu, 27 Apr 2023 07:16:35 -0400 X-MC-Unique: dDiRwWslO2eJ1Q0kVbVO8Q-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 5CFBB101A550 for ; Thu, 27 Apr 2023 11:16:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2872BC15BA0 for ; Thu, 27 Apr 2023 11:16:35 +0000 (UTC) From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Subject: [PATCH] doc: Describe behaviour of enums with fixed underlying type Date: Thu, 27 Apr 2023 12:16:34 +0100 Message-Id: <20230427111634.1728893-1-jwakely@redhat.com> MIME-Version: 1.0 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: C2x adds the ability to give an enumeration type a fixed underlying type, as C++ already has. The -fshort-enums option alters the compiler's choice of underlying type, but when it's fixed the compiler can't choose. Similarly for C++ -fstrict-enums has no effect with a fixed underlying type, because every value of the underlying type is a valid value of the enumeration type. This caused confusion recently: https://gcc.gnu.org/PR109532 OK for trunk? -- >8 -- gcc/ChangeLog: * doc/invoke.texi (Code Gen Options): Note that -fshort-enums is ignored for a fixed underlying type. (C++ Dialect Options): Likewise for -fstrict-enums. --- gcc/doc/invoke.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2f40c58b21c..0f91464f8c0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3495,6 +3495,8 @@ defined in the C++ standard; basically, a value that can be represented in the minimum number of bits needed to represent all the enumerators). This assumption may not be valid if the program uses a cast to convert an arbitrary integer value to the enumerated type. +This option has no effect for an enumeration type with a fixed underlying +type. @opindex fstrong-eval-order @item -fstrong-eval-order @@ -18303,6 +18305,8 @@ Use it to conform to a non-default application binary interface. Allocate to an @code{enum} type only as many bytes as it needs for the declared range of possible values. Specifically, the @code{enum} type is equivalent to the smallest integer type that has enough room. +This option has no effect for an enumeration type with a fixed underlying +type. @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate code that is not binary compatible with code generated without that switch. -- 2.40.0