This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] tile: Fix up corner cases with signed relocations
- From: Rich Felker <dalias at libc dot org>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: Chris Metcalf <cmetcalf at tilera dot com>, Andreas Schwab <schwab at linux-m68k dot org>, libc-alpha at sourceware dot org
- Date: Mon, 8 Sep 2014 11:55:32 -0400
- Subject: Re: [PATCH] tile: Fix up corner cases with signed relocations
- Authentication-results: sourceware.org; auth=none
- References: <201409051854 dot s85IsfM0024659 at gx-1 dot internal dot tilera dot com> <8761h1hkog dot fsf at linux-m68k dot org> <540A1F34 dot 2020303 at tilera dot com> <871trphhkr dot fsf at linux-m68k dot org> <540B3349 dot 1000507 at tilera dot com> <Pine dot LNX dot 4 dot 64 dot 1409081518450 dot 6075 at digraph dot polyomino dot org dot uk> <20140908152707 dot GG23797 at brightrain dot aerifal dot cx> <Pine dot LNX dot 4 dot 64 dot 1409081530150 dot 6075 at digraph dot polyomino dot org dot uk>
On Mon, Sep 08, 2014 at 03:34:18PM +0000, Joseph S. Myers wrote:
> On Mon, 8 Sep 2014, Rich Felker wrote:
>
> > > In any case, the GNU C language defines signed shifts (as long as the
> > > shift amount is >= 0 and < width of type), although it may still be useful
> > > to avoid the cases that are outside what ISO C defines.
> >
> > I don't think this is true. For example, in many versions of GCC, this
> > is (rightfully!) an infinite loop:
> >
> > int i;
> > for (i=1; i>0; i<<=1);
>
> That would be a bug (I fixed such a bug ten years ago, PR 7284); please
> report it if present in trunk. Signed shifts are documented in
> implement-c.texi; C90 makes some things implementation-defined even when
> C99/C11 make them undefined.
OK, yet another reason to avoid << operator: GCC intentionally fails
to optimize it right. Thankfully *(1<<y) solves that too.
As for versions where the above loop condition gets optimized out, I
don't recall which ones, but I do recall seeing it (broken configure
scripts checking the range of time_t going into an infinite loop) in
the past 3 or 4 years. But it's very possible that the users who
experienced it were using a much older version of GCC such as 3.4,
4.2, or 4.4.
Rich