This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb: Use std::max and std::min throughout
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: palves at redhat dot com (Pedro Alves)
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 19 Sep 2016 13:47:24 +0200 (CEST)
- Subject: Re: [PATCH] gdb: Use std::max and std::min throughout
- Authentication-results: sourceware.org; auth=none
Pedro Alves wrote:
> gdb/ChangeLog:
> 2016-09-16 Pedro Alves <palves@redhat.com>
>
> * defs.h (min, max): Delete.
> * aarch64-tdep.c: Include <algorithm> and use std::min and
> std::max throughout.
This causes build failures on many files on my SPU daily build. This
may be related to the fact that I'm using --disable-nls and/or that I'm
building on RHEL 5 using a GCC 4.1 host compiler.
The symptom is:
/usr/include/libintl.h:40: error: expected unqualified-id before â??constâ??
/usr/include/libintl.h:40: error: expected `)' before â??constâ??
/usr/include/libintl.h:40: error: expected initializer before â??constâ??
/usr/include/libintl.h:45: error: expected unqualified-id before â??constâ??
/usr/include/libintl.h:45: error: expected `)' before â??constâ??
/usr/include/libintl.h:45: error: expected initializer before â??constâ??
/usr/include/libintl.h:52: error: expected unqualified-id before â??constâ??
/usr/include/libintl.h:52: error: expected `)' before â??constâ??
/usr/include/libintl.h:52: error: expected initializer before â??constâ??
/usr/include/libintl.h:83: error: expected unqualified-id before â??whileâ??
/usr/include/libintl.h:83: error: expected initializer before â??whileâ??
/usr/include/libintl.h:87: error: expected unqualified-id before â??whileâ??
/usr/include/libintl.h:87: error: expected initializer before â??whileâ??
Line 40 in this header is originally:
extern char *gettext (__const char *__msgid)
__THROW __attribute_format_arg__ (1);
but after preprocessing we get:
extern char *(__const char *__msgid)
throw () __attribute__ ((__format_arg__ (1)));
which is obviously broken.
It seems the reason for this is a GDB header trick in common/gdb_locale.h:
#ifdef ENABLE_NLS
...
#else
# define gettext(Msgid) (Msgid)
...
#endif
This will obviously cause problems if the <libintl.h> header is included
at any point after "gdb_locale.h" (which is in turn included by "defs.h"
via "common-defs.h", and thus by any GDB file).
Apparently in the past this newer happened. But after your change to
include <algorithm>, this is now triggered, since (at least the GCC 4.1
copy of) <algorihm> includes <libintl.h> via <bits/stl_algobase.h>,
<iosfwd>, and <bits/c++locale.h>.
Any thoughts how to fix this?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com