-Og bug?

Thomas Schwinge thomas@codesourcery.com
Tue Jan 28 16:11:00 GMT 2014


Hi!

On Tue, 28 Jan 2014 06:52:30 -0800, Ian Lance Taylor <iant@google.com> wrote:
> On Tue, Jan 28, 2014 at 6:36 AM, Thomas Schwinge
> <thomas@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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140128/bad9092a/attachment.sig>


More information about the Gcc-patches mailing list