From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13340 invoked by alias); 22 May 2014 06:52:54 -0000 Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org Received: (qmail 13322 invoked by uid 89); 22 May 2014 06:52:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-oa0-f48.google.com Received: from mail-oa0-f48.google.com (HELO mail-oa0-f48.google.com) (209.85.219.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 22 May 2014 06:52:52 +0000 Received: by mail-oa0-f48.google.com with SMTP id i4so3455764oah.21 for ; Wed, 21 May 2014 23:52:50 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.58.71 with SMTP id o7mr28952886oeq.67.1400741570726; Wed, 21 May 2014 23:52:50 -0700 (PDT) Received: by 10.60.31.65 with HTTP; Wed, 21 May 2014 23:52:50 -0700 (PDT) In-Reply-To: References: <20140522052921.GA30609@chokladfabriken.org> Date: Thu, 22 May 2014 06:52:00 -0000 Message-ID: Subject: Re: [PATCH] Make large enum constants unsigned From: Stefan Kristiansson To: "Maciej W. Rozycki" Cc: Stefan Kristiansson , cgen@sourceware.org, Alan Modra , fche@sourceware.org, Christian Svensson , Pierre Muller Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-q2/txt/msg00007.txt.bz2 On Thu, May 22, 2014 at 9:21 AM, Maciej W. Rozycki wrote: > On Thu, 22 May 2014, Stefan Kristiansson wrote: > >> this fixes a bug noted in two threads on the binutils mailing list: >> https://sourceware.org/ml/binutils/2014-05/msg00152.html >> https://sourceware.org/ml/binutils/2014-05/msg00195.html >> >> Both threads describe the problem pretty well, but the gist of it >> is that constants are generated that will be interpreted as signed. >> >> 2014-05-22 Stefan Kristiansson >> >> * enum.scm (gen-enum-decl): Emit 'ULL' after constants larger than >> #x80000000 > > Well, `ULL' is non-standard for pre-C99 compilers and also not needed > because an enum will never have a type that is wider than `int'. So for > portability's sake I suggest that you use `U' or `u' as I proposed (I > prefer lowercase `u' for decimal constants because I find it easier to > spot among digits, however please feel free to take your pick). > Hmm, right. I actually had a plain 'U' in my first version of the patch, but then changed it to 'ULL' last minute with the thought of being future proof against possible larger mask values. But as you point out, that will have issues anyway, so I'll repost with the original patch. As for 'u' vs 'U', a 'U' is emitted in the .h file even if I put a 'u' in the .scm. If 'u' in the output is preferred, maybe someone can point out the reason for this? Stefan