220 40119 <b6bee554-139b-4673-bbc2-a688a8a35e84@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: gmisocpp@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: enumerator duplicated value attribute
Date: Sat, 8 Sep 2018 17:30:05 -0700 (PDT)
Lines: 148
Approved: news@gmane.org
Message-ID: <b6bee554-139b-4673-bbc2-a688a8a35e84@isocpp.org>
References: <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com>
 <e08984e8-9697-44d9-a603-2af646852647@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_681_278034914.1536453006087"
X-Trace: blaine.gmane.org 1536452882 7296 195.159.176.226 (9 Sep 2018 00:28:02 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 9 Sep 2018 00:28:02 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCM3TRNUXUDBBD6T2HOAKGQEM7PE64Y@isocpp.org Sun Sep 09 02:27:58 2018
Return-path: <std-proposals+bncBCM3TRNUXUDBBD6T2HOAKGQEM7PE64Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f69.google.com ([209.85.161.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCM3TRNUXUDBBD6T2HOAKGQEM7PE64Y@isocpp.org>)
	id 1fyna1-0001n7-Un
	for gclcip-std-proposals@m.gmane.org; Sun, 09 Sep 2018 02:27:58 +0200
Original-Received: by mail-yw1-f69.google.com with SMTP id d23-v6sf11462858ywb.2
        for <gclcip-std-proposals@m.gmane.org>; Sat, 08 Sep 2018 17:30:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=PdypavcROc4+/wApJ1q5RADqZyKNeV/6DtIUrXDHZdc=;
        b=V1aG2aDR9+Ol58qEEhHCzljMOURcpsSmptZqh6EIP3l2wwuLILhVG+fYhVlK9dhLAV
         1xDEQSJjQ8xnhdwpXTIacHADL2O92NWH1ydn3J2u2vXFkJQjMf34szRFMCUysR048QEp
         XaM/DPfYoLCjcnhUDlEAVdPv0L8BEZ7/KuE5wwnCiYF27aA7iAyuEmyDSMgmvdJItv5V
         vFCxqMqraaQp3Rb0pyFnsmurf0SWo32vqiPqkLsTvvsJKSHC9fm2aa4VHYOML6m41i3Z
         kPjgnBwpFUCnjq+kbrltJCXurcnt5gyE5mjwqxrKiQH9sUHrFYuE3qrR+YX5V+heyEZx
         1ktA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=PdypavcROc4+/wApJ1q5RADqZyKNeV/6DtIUrXDHZdc=;
        b=rGgu+VLdm8AcFZe7ZLgD/i23tYdqC/r/n6z87LibvKzl5bhINVWby2YXig398fJfpI
         M9jihA6EoLO5OlPUFSMBOJbxdvoE7YsL83+2lN65shGmZhLbrOGjdUIpKNEMPgj1wA6e
         XaPJDeWlPXwJjnZ0U9NVKzV8mEvj24VDtQFkPzZCA2A6zO28TIvpacqSJ38sEwBSHmXd
         EswynzbpVZyfmIX7IjRVvbtkRLqsZ0RDuskEBqW0dWF/OasBAzK/K/4KUNj2jzY8Rm4d
         N/WO2rUFLvEc79qUD5tfQ3p3LymMSPst7AspB7qP3zk8TQHUYVrym5s+r2j1RMEX/vDf
         rEoQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=PdypavcROc4+/wApJ1q5RADqZyKNeV/6DtIUrXDHZdc=;
        b=OoNNhgEJZT4zniX6Khc9Q0yKJmDppRbIfOAuPezMKsTnuLPF74alx0txkFq1Ir2F1q
         qN3eGdRIRnEFm3AyJAuFO1rU/7t6fUl+QFNWdgt3O4KhrdSibgbfA27W8VKpI/ir6Mx1
         n2K7rY7+cxfVIHQJoJQUbUFVkiv1+IcfENe5ZTm9kx4Jhv02LJnL/dzVgWumjT2ov5Na
         IeSZKlW13LnPOK8ruBaaAVi4BctGZHv3VCqoPDbxPK816wDv+iEmVbeHnRc8+kqrj0w/
         2GQ0QxPV8EF7ja+hlby+AuzTOy/rCAEc3MbrXsCXYzjh5wwCbvoy14L93BQxc3lOizAg
         O7jw==
X-Gm-Message-State: APzg51BpXrB8LrJJ4TUkwY3ylpi9xXeQ8Lw/6Py5ywi0XnilJl3ReHok
	L5acA9xxOOb4Z7OVjsQ+xCyNqw==
X-Google-Smtp-Source: ANB0VdbDW+nZet5It9NtQf52j4SXWZj0+q4qMaJ3Y78ciGWWVvEVxL/7x3aIb9q9v8i92j3RZpbY/w==
X-Received: by 2002:a25:410f:: with SMTP id o15-v6mr3428381yba.69.1536453008128;
        Sat, 08 Sep 2018 17:30:08 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:50f:: with SMTP id 15-v6ls795508ybf.17.gmail; Sat, 08
 Sep 2018 17:30:06 -0700 (PDT)
X-Received: by 2002:a25:ba44:: with SMTP id z4-v6mr133372ybj.7.1536453006829;
        Sat, 08 Sep 2018 17:30:06 -0700 (PDT)
In-Reply-To: <e08984e8-9697-44d9-a603-2af646852647@isocpp.org>
X-Original-Sender: gmisocpp@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40119
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40119>

------=_Part_681_278034914.1536453006087
Content-Type: multipart/alternative; 
	boundary="----=_Part_682_1969118459.1536453006088"

------=_Part_682_1969118459.1536453006088
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I haven't ever had a need for this feature, but since clang supports a=20
warning for it, it seems it might be reasonable to have it as a standard=20
feature. Which is what the OP is asking for?
So it's good you provided the information that there is a solution that=20
might work for his compiler, but would you vote for a standard way to do=20
this? I think that's the question.

On Saturday, September 8, 2018 at 1:11:32 PM UTC+12, Arthur O'Dwyer wrote:

> On Friday, September 7, 2018 at 11:55:57 AM UTC-7, Daniel Gutson wrote:
>>
>> Hi,
>>
>>    sometimes is important to prevent duplication of enumerators in the=
=20
>> enumerations. That's why some compilers such as clang has the=20
>> -Wduplicate-enum.
>> However there are cases such as ranges within enums, where enumerators=
=20
>> define a category and then are followed by the first element of the=20
>> category, with the same value.
>>
>> enum Ranges
>> {
>>     CategoryX =3D 100,
>>        X1 =3D CategoryX,
>>        X2,
>>        X3
>>      CategoryY =3D 200
>>        // ...
>> };
>>
>
> What Chris said: this code is already acceptable to Clang.
> However, if you do ever run into a situation where Clang is giving you a=
=20
> warning that is "usually correct but I don't want to see it in this=20
> particular case," there already exists markup to indicate that situation:
>
> enum Ranges {
>     CategoryX =3D 100,
>     X1 =3D CategoryX,
>     X2,
>     X3,
> #pragma clang diagnostic push
> #pragma clang diagnostic ignored "-Wduplicate-enum"
>     DeprecatedNameX1 =3D X1,
>     DeprecatedNameX2,
>     DeprecatedNameX3,
> #pragma clang diagnostic pop
> };
>
> Unfortunately, Clang currently has what-I-consider-a-bug in that it=20
> requires you to put the pragma on the *first* occurrence of the value,=20
> rather than on the *duplicate* occurrence. I've filed a bug report=20
> <https://bugs.llvm.org/show_bug.cgi?id=3D38876>.
>
> =E2=80=93Arthur
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/b6bee554-139b-4673-bbc2-a688a8a35e84%40isocpp.or=
g.

------=_Part_682_1969118459.1536453006088
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I haven&#39;t ever had a need for this=C2=A0feature, =
but since clang supports a warning for it, it seems it might be reasonable =
to have it as a standard feature. Which is what the OP is asking for?</div>=
<div>So it&#39;s good you provided the information that there is a solution=
 that might work for his compiler, but would you vote for a standard way to=
 do this? I think=C2=A0that&#39;s the question.<br><br>On Saturday, Septemb=
er 8, 2018 at 1:11:32 PM UTC+12, Arthur O&#39;Dwyer wrote:</div><blockquote=
 class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1e=
x; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-le=
ft-style: solid;"><div dir=3D"ltr">On Friday, September 7, 2018 at 11:55:57=
 AM UTC-7, Daniel Gutson wrote:<blockquote class=3D"gmail_quote" style=3D"m=
argin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 20=
4, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr=
">Hi,<div><br></div><div>=C2=A0 =C2=A0sometimes is important to prevent dup=
lication of enumerators in the enumerations. That&#39;s why some compilers =
such as clang has the -Wduplicate-enum.</div><div>However there are cases s=
uch as ranges within enums, where enumerators define a category and then ar=
e followed by the first element of the category, with the same value.</div>=
<div><br></div><div>enum Ranges</div><div>{</div><div>=C2=A0 =C2=A0 Categor=
yX =3D 100,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X1 =3D CategoryX,</div><di=
v>=C2=A0 =C2=A0 =C2=A0 =C2=A0X2,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X3</d=
iv><div>=C2=A0 =C2=A0 =C2=A0CategoryY =3D 200</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0// ...</div><div>};</div></div></blockquote><div><br></div><div>W=
hat Chris said: this code is already acceptable to Clang.</div><div>However=
, if you do ever run into a situation where Clang is giving you a warning t=
hat is &quot;usually correct but I don&#39;t want to see it in this particu=
lar case,&quot; there already exists markup to indicate that situation:</di=
v><div><br></div><div>enum Ranges {</div><div>=C2=A0 =C2=A0 CategoryX =3D 1=
00,</div><div>=C2=A0 =C2=A0 X1 =3D CategoryX,</div><div>=C2=A0 =C2=A0 X2,</=
div><div>=C2=A0 =C2=A0 X3,</div><div>#pragma clang diagnostic push</div><di=
v>#pragma clang diagnostic ignored &quot;-Wduplicate-enum&quot;</div><div>=
=C2=A0 =C2=A0 DeprecatedNameX1 =3D X1,</div><div>=C2=A0 =C2=A0=C2=A0Depreca=
tedNameX2,</div><div>=C2=A0 =C2=A0=C2=A0DeprecatedNameX3,</div><div>#pragma=
 clang diagnostic pop</div><div>};</div><div><br></div><div>Unfortunately, =
Clang currently has what-I-consider-a-bug in that it requires you to put th=
e pragma on the <i>first</i> occurrence of the value, rather than on the <i=
>duplicate</i> occurrence. I&#39;ve filed <a onmousedown=3D"this.href=3D&#3=
9;https://www.google.com/url?q\x3dhttps%3A%2F%2Fbugs.llvm.org%2Fshow_bug.cg=
i%3Fid%3D38876\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF8ANaVgaQEaQM-Iu2Rqp=
lUTpeUoQ&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fbugs.llvm.org%2Fshow_bug.cgi%3Fid%3D38876\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF8ANaVgaQEaQM-Iu2RqplUTpeUoQ&#39;;return =
true;" href=3D"https://bugs.llvm.org/show_bug.cgi?id=3D38876" target=3D"_bl=
ank" rel=3D"nofollow">a bug report</a>.</div><div><br></div><div>=E2=80=93A=
rthur</div></div></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b6bee554-139b-4673-bbc2-a688a8a35e84%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b6bee554-139b-4673-bbc2-a688a8a35e84=
%40isocpp.org</a>.<br />

------=_Part_682_1969118459.1536453006088--

------=_Part_681_278034914.1536453006087--

.
