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 987873858D1E for ; Tue, 2 May 2023 20:43:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 987873858D1E 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=1683060197; h=from:from: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=afGKwWt1pTwsqyesArof+Ore6ERggXX0hHmKiNRP54c=; b=io0bpuS31lhWOstxYMIipSd2JiQiOzhjEnpnsI3kEMYDz+aQTfFN9DhH0wpiQUpEyvu4OP MBM9VVD+0T9njHUu9bqf9sm4Xi8sYqGFVgfUBsvnV5PtSDz1M+XRG8LDleD5+fbbFI9unc rXdOJYnIprLS6LdAXBlKVEvdnjnF608= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-ao6R_6wbPnyNoA2fNTqHgQ-1; Tue, 02 May 2023 16:43:15 -0400 X-MC-Unique: ao6R_6wbPnyNoA2fNTqHgQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2a8bba7dd2cso20416161fa.2 for ; Tue, 02 May 2023 13:43:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683060194; x=1685652194; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=afGKwWt1pTwsqyesArof+Ore6ERggXX0hHmKiNRP54c=; b=YdVGirHgMX1+98bBETB/xI+oTuwo2WJyiFHI+dqNbY66KmaxIiwuW3tZ/t77lHbUwj xikRZDFBhGBgX5J81hIUrRCo9Hw4VoXJ2fVKQKilHSZsoYbqNm/MpVoQshXt6rq8nmtR RUaKVI3NyVzglHl3EE9YyLo+itCMWq6KWwPsYSpQgrBLdArm5/p6w82yXDNto281VkuX H7Lu+yU5mfE9H+iGe94jxAbj7KIpM0cWsCChiM+XiSTMdnGafP8hsvecU0sZsr3/oRwQ U2U/EYTm9RYmAvy7GRsWLrDgIaPQgeanGzYjYU0GyC4z/QUiun8rBFy2H6BFUgVm26lE qtQw== X-Gm-Message-State: AC+VfDyPaRPRZg8JuscAyBowavAuFPr+KLDPPXY3RVxl5nKsF5CFFeAK StlQd4ERswPJJa3EjZ1zNADIUQ9pByBN6FxwTG4fkWF9SYCKwlkw6VR+s+Vr347x9p59eQZZISf Z51p0wZm+qmUj458+Q6Fd337++vbaPu0Erg== X-Received: by 2002:a2e:888f:0:b0:2a8:bc34:c1d3 with SMTP id k15-20020a2e888f000000b002a8bc34c1d3mr5418669lji.40.1683060194080; Tue, 02 May 2023 13:43:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4c4/gdSLiZftnI56ePEv3hbVuoumMETjVjijX2eH3aN75Mk8ZHzN4wrBGeowncalVzPbY6k8K6vhHC9QK9Bas= X-Received: by 2002:a2e:888f:0:b0:2a8:bc34:c1d3 with SMTP id k15-20020a2e888f000000b002a8bc34c1d3mr5418664lji.40.1683060193713; Tue, 02 May 2023 13:43:13 -0700 (PDT) MIME-Version: 1.0 References: <20230427111634.1728893-1-jwakely@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Tue, 2 May 2023 21:43:02 +0100 Message-ID: Subject: Re: [PATCH] doc: Describe behaviour of enums with fixed underlying type To: Marek Polacek Cc: gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000fb7aa505fabbfc03" X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,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: --000000000000fb7aa505fabbfc03 Content-Type: text/plain; charset="UTF-8" On Thu, 27 Apr 2023 at 16:58, Marek Polacek wrote: > On Thu, Apr 27, 2023 at 12:16:34PM +0100, Jonathan Wakely via Gcc-patches > wrote: > > 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? > > LGTM. > That's an ack C front end reviewer (thanks!), do I need an ack from a C++/docs/global review too, or can I push? > > > -- >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 > > > > Marek > > --000000000000fb7aa505fabbfc03--