Hi!

On Tue, 28 Jan 2014 06:52:30 -0800, Ian Lance Taylor <i...@google.com> wrote:
> On Tue, Jan 28, 2014 at 6:36 AM, Thomas Schwinge
> <tho...@codesourcery.com> wrote:
> > Avoid "'dc' may be uninitialized" warning.
> >
> >         libiberty/
> >         * cp-demangle.c (d_demangle_callback): Put __builtin_unreachable
> >         in place, to help the compiler.

For my own education: why is this not considered a GCC trunk bug?  It is
xgcc/cc1 which is coming up with this (bogus?) warning, but only for -Og
and not for -O0, -O1, etc.?

> > --- libiberty/cp-demangle.c
> > +++ libiberty/cp-demangle.c
> > @@ -5824,6 +5824,8 @@ d_demangle_callback (const char *mangled, int options,
> >                           NULL);
> >         d_advance (&di, strlen (d_str (&di)));
> >         break;
> > +      default:
> > +       __builtin_unreachable ();
> 
> You can't call __builtin_unreachable in this code, because libiberty
> in stage 1 will be compiled by the host compiler and
> __builtin_unreachable is specific to GCC.

Right, thanks for catching that.

> This patch is OK if you call abort instead of __builtin_unreachable.

As soon as I'm clear that this is not in fact a GCC bug, I'll commit the
following.  <stdlib.h> already is being included.  Source code comment
snatched from regex.c.

Avoid "'dc' may be uninitialized" warning.

        libiberty/
        * cp-demangle.c (d_demangle_callback): Put an abort call in
        place, to help the compiler.

--- libiberty/cp-demangle.c
+++ libiberty/cp-demangle.c
@@ -5824,6 +5824,8 @@ d_demangle_callback (const char *mangled, int options,
                          NULL);
        d_advance (&di, strlen (d_str (&di)));
        break;
+      default:
+       abort (); /* We have listed all the cases.  */
       }
 
     /* If DMGL_PARAMS is set, then if we didn't consume the entire


Grüße,
 Thomas

Attachment: pgpPnuJ5Z7Alx.pgp
Description: PGP signature

Reply via email to