From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73224 invoked by alias); 20 Jan 2016 14:41:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 73210 invoked by uid 89); 20 Jan 2016 14:41:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1476, 0x02, 0x04 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 20 Jan 2016 14:41:33 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B7A3332D3AC; Wed, 20 Jan 2016 14:41:31 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0KEfUIt000904; Wed, 20 Jan 2016 09:41:31 -0500 Message-ID: <569F9C9A.7090307@redhat.com> Date: Wed, 20 Jan 2016 14:41:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter References: <1453177390-13881-1-git-send-email-simon.marchi@polymtl.ca> <569E17C5.6080909@redhat.com> <35bba9e534e14532c11ad7c0a5c1db2b@simark.ca> In-Reply-To: <35bba9e534e14532c11ad7c0a5c1db2b@simark.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-01/txt/msg00474.txt.bz2 On 01/19/2016 04:41 PM, Simon Marchi wrote: > On 2016-01-19 06:02, Pedro Alves wrote: >> Thanks for catching this. >> >> I find it surprising that the printer doesn't respect the >> order of the values as they're defined though. Shouldn't we >> remove the sort line entirely, thus keeping the >> existing behavior? I couldn't find mention of the sorting >> in the documentation either. >> >> Or, maybe the printer doesn't work correctly if the "overlapping" >> value (which I think it the whole point of this printer) is defined >> before the particular values, like, e.g.: >> >> enum flag_enum >> { >> ALL = 1 | 2 | 4, >> FLAG_2 = 2, >> FLAG_3 = 4, >> FLAG_1 = 1, >> }; >> >> ? > > If we don't sort the values and ALL is defined first, then 0x7 will be > displayed as ALL instead of FLAG_1 | FLAG_2 | FLAG_3. I don't think > either is wrong, we just don't know which one each particular user > would prefer. So I think we can choose one way (sorted order, or > definition order) and stick with it. > > Personally, I think I would prefer the more explicit version > (FLAG_1 | FLAG_2 | FLAG_3), which means keeping the sort. OK, I think that makes sense for cases like: enum flag_enum { FOO_MASK = 0x07, FOO_1 = 0x01, FOO_2 = 0x02, FOO_3 = 0x04, BAR_MASK = 0x70, BAR_1 = 0x10, BAR_2 = 0x20, BAR_3 = x040, }; Would you mind augmenting the testsuite with something like this, then? Thanks, Pedro Alves