From: Jason Merrill Date: Thu, 3 Dec 2020 21:38:19 +0000 (-0500) Subject: c++: Fix bootstrap on 32-bit hosts [PR91828] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9a7f5e3906560b7a894047caf146d7c21cb02f2b;p=gcc.git c++: Fix bootstrap on 32-bit hosts [PR91828] Using the releasing_vec op[] with an int index was breaking on 32-bit hosts because of ambiguity with the built-in operator and the conversion function. Since the built-in operator has a ptrdiff_t, this was fine on 64-bit targets where ptrdiff_t is larger than int, but broke on 32-bit targets where it's the same as int, making the conversion for that argument better than the member function. Fixed by changing the member function to also use ptrdiff_t for the index. gcc/cp/ChangeLog: * cp-tree.h (releasing_vec::operator[]): Change parameter type to ptrdiff_t. --- diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 081ede24e96..f28291e46d7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -975,8 +975,10 @@ public: operator vec_t *() const { return v; } vec_t ** operator& () { return &v; } - /* Breaks pointer/value consistency for convenience. */ - tree& operator[] (unsigned i) const { return (*v)[i]; } + /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t + rather than unsigned to avoid ambiguity with the built-in operator[] + (bootstrap/91828). */ + tree& operator[] (ptrdiff_t i) const { return (*v)[i]; } ~releasing_vec() { release_tree_vector (v); } private: