This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C/C++ PATCH] Implement -Wshift-negative-value (PR c/65179)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Steve Ellcey <sellcey at imgtec dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, Jeff Law <law at redhat dot com>, Martin Sebor <msebor at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Paul Eggert <eggert at cs dot ucla dot edu>
- Date: Fri, 8 May 2015 16:59:19 +0000
- Subject: Re: [C/C++ PATCH] Implement -Wshift-negative-value (PR c/65179)
- Authentication-results: sourceware.org; auth=none
- References: <20150507191532 dot GH3384 at redhat dot com> <1431103107 dot 14613 dot 192 dot camel at ubuntu-sellcey>
On Fri, 8 May 2015, Steve Ellcey wrote:
> On Thu, 2015-05-07 at 21:15 +0200, Marek Polacek wrote:
> > On Thu, May 07, 2015 at 12:00:20PM -0600, Jeff Law wrote:
> > > OK. Please install if you haven't already.
> >
> > I have not, so will do momentarily. Thanks,
> >
> > Marek
>
> Marek,
>
> This patch has broken the glibc build. I am not sure if the problem is
> a bug in your patch or a bug in the code used by glibc. Here is a
> cutdown test case from glibc (timezone/scheck.c). This code compiled
> before your patch but now it fails with:
>
> x.c:4:3: error: initializer element is not constant
> ((((time_t) -1) < 0)
>
>
>
> __extension__ typedef long int __time_t;
> typedef __time_t time_t;
> static time_t const time_t_min =
> ((((time_t) -1) < 0)
> ? (time_t) -1 << (8 * sizeof (time_t) - 1)
> : 0)
Paul, although glibc's copy of parts of tzcode is a bit out of date, it
looks like the current https://github.com/eggert/tz.git still has the
problematic code in private.h, relying on left-shifting -1 which has
undefined behavior in C99/C11 (implementation-defined in C90, as per
DR#081).
--
Joseph S. Myers
joseph@codesourcery.com