This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Fix GDB build with G++ 4.8


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cc536b21677586455973f81ee05257ada8efdcb8

commit cc536b21677586455973f81ee05257ada8efdcb8
Author: Pedro Alves <palves@redhat.com>
Date:   Mon Oct 2 10:18:30 2017 +0100

    Fix GDB build with G++ 4.8
    
    G++ 4.8 trips on:
    
      In file included from /opt/gcc-4.8/include/c++/4.8.5/algorithm:62:0,
    		   from ../../src/gdb/ada-lang.c:65:
      /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h: In instantiation of â??_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Tp = ada_exc_info]â??:
      /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2283:70:   required from â??_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]â??
      /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2315:54:   required from â??void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Size = long int]â??
      /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:5461:36:   required from â??void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]â??
      ../../src/gdb/ada-lang.c:13153:61:   required from here
      /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2245:19: error: passing â??const ada_exc_infoâ?? as â??thisâ?? argument of â??bool ada_exc_info::operator<(const ada_exc_info&)â?? discards qualifiers [-fpermissive]
          while (__pivot < *__last)
    		     ^
    
    Seems to be a libstdc++ bug meanwhile fixed by:
      https://gcc.gnu.org/ml/libstdc++/2012-04/msg00074.
    
    In any case, there's no reason these methods can't be const.
    
    gdb/ChangeLog:
    2017-10-02  Tom Tromey  <tom@tromey.com>
    	    Pedro Alves  <palves@redhat.com>
    
    	* ada-lang.h (ada_exc_info::operator<): Make const.
    	(ada_exc_info::operator==): Make const.
    	* ada-lang.c (ada_exc_info::operator<, ada_exc_info::operator==):
    	Make const.

Diff:
---
 gdb/ChangeLog  | 8 ++++++++
 gdb/ada-lang.c | 4 ++--
 gdb/ada-lang.h | 4 ++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ed5d20c..9bdb6f8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-10-02  Tom Tromey  <tom@tromey.com>
+	    Pedro Alves  <palves@redhat.com>
+
+	* ada-lang.h (ada_exc_info::operator<): Make const.
+	(ada_exc_info::operator==): Make const.
+	* ada-lang.c (ada_exc_info::operator<, ada_exc_info::operator==):
+	Make const.
+
 2017-09-29  Tom Tromey  <tom@tromey.com>
 
 	* target.c (read_whatever_is_readable): Change type of "result".
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7e9f06c..1a0c769 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13123,7 +13123,7 @@ ada_is_non_standard_exception_sym (struct symbol *sym)
    by exception address.  */
 
 bool
-ada_exc_info::operator< (const ada_exc_info &other)
+ada_exc_info::operator< (const ada_exc_info &other) const
 {
   int result;
 
@@ -13136,7 +13136,7 @@ ada_exc_info::operator< (const ada_exc_info &other)
 }
 
 bool
-ada_exc_info::operator== (const ada_exc_info &other)
+ada_exc_info::operator== (const ada_exc_info &other) const
 {
   return addr == other.addr && strcmp (name, other.name) == 0;
 }
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index f92b88d..a47fe82 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -387,8 +387,8 @@ struct ada_exc_info
   /* The address of the symbol corresponding to that exception.  */
   CORE_ADDR addr;
 
-  bool operator< (const ada_exc_info &);
-  bool operator== (const ada_exc_info &);
+  bool operator< (const ada_exc_info &) const;
+  bool operator== (const ada_exc_info &) const;
 };
 
 extern std::vector<ada_exc_info> ada_exceptions_list (const char *regexp);


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