[PATCH] [PATCH] [gdb] adds `<iterator>` to list of includes

Christopher Di Bella cjdb@google.com
Fri Jul 1 21:50:55 GMT 2022


Hi Enze,

`std::back_inserter` is defined in <iterator>, which isn't included in
`gdb/value.c`. Because the C preprocessor imports headers by copy/pasting
the contents at the `#include` site, this means that another standard
library header is exposing it (presumably `<algorithm>`).

We experienced this on ChromeOS, which uses Clang and libc++ to build
things.

```
/tmp/portage/sys-devel/gdb-9.2.20200923-r7/work/gdb-9.2/gdb/value.c:1648:52:
error: no member named 'back_inserter' in namespace 'std'
       std::move (iter + 1, all_values.end (), std::back_inserter (result));
                                               ~~~~~^
 1 error generated.
```

On Fri, 1 Jul 2022 at 06:45, Enze Li <enze.li@hotmail.com> wrote:

> On Tue, 2022-06-28 at 01:04 +0000, Christopher Di Bella via Gdb-patches
> wrote:
> > `std::back_inserter` is defined in `<iterator>`, which is currently
> > being transitively included by one of the other headers. This is
> > causing
> > gdb to fail to build on certain platforms, which is fixed by
> > explicitly
> > including it.
>
> Hi Christopher,
>
> I didn't get your point through the commit message.  Can you clarify
> exactly on which platforms, and what build error you encountered?  So
> that I can reproduce the issue.
>
> Thanks,
> Enze
>
>
> > ---
> >  gdb/value.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/gdb/value.c b/gdb/value.c
> > index 022fca91a42..ba7ae1a0e18 100644
> > --- a/gdb/value.c
> > +++ b/gdb/value.c
> > @@ -40,6 +40,7 @@
> >  #include "cp-abi.h"
> >  #include "user-regs.h"
> >  #include <algorithm>
> > +#include <iterator>
> >  #include "completer.h"
> >  #include "gdbsupport/selftest.h"
> >  #include "gdbsupport/array-view.h"
>
>

-- 
Kind regards,

Christopher Di Bella (he/him/his)


More information about the Gdb-patches mailing list