This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb: Use std::max and std::min throughout


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]