[2/2] symtab reader: fix symtab iterator to support C++20

Message ID 20230606085132.1894137-4-maennich@google.com
State New
Headers
Series [1/2] symtab reader: use C++11 `using` syntax instead of typedefs |

Commit Message

Matthias Männich June 6, 2023, 8:51 a.m. UTC
  From: Matthias Maennich <maennich@google.com>

Inheriting from std::vector::iterator causes the type to advertise
itself as a contiguous iterator. This causes a compilation error in
newer versions of libc++ that try to use contiguous-iterator-specific
optimizations in those situations. Fixed thus by explicitly specifying
the interator_concept tag.

	* abg-symtab-reader.h (symtab_iterator): Specify
	  iterator_concept as forward_iterator to support C++20 compilation.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-symtab-reader.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Giuliano Procida June 7, 2023, 6:53 a.m. UTC | #1
On Tue, 6 Jun 2023 at 09:52, Matthias Männich <maennich@google.com> wrote:
>
> From: Matthias Maennich <maennich@google.com>
>
> Inheriting from std::vector::iterator causes the type to advertise
> itself as a contiguous iterator. This causes a compilation error in
> newer versions of libc++ that try to use contiguous-iterator-specific
> optimizations in those situations. Fixed thus by explicitly specifying
> the interator_concept tag.
>
>         * abg-symtab-reader.h (symtab_iterator): Specify
>           iterator_concept as forward_iterator to support C++20 compilation.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>

Reviewed-by: Giuliano Procida <gprocida@google.com>

> ---
>  src/abg-symtab-reader.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h
> index 7477cca5a6f0..888a56822224 100644
> --- a/src/abg-symtab-reader.h
> +++ b/src/abg-symtab-reader.h
> @@ -115,6 +115,7 @@ public:
>    using pointer = base_iterator::pointer;
>    using difference_type = base_iterator::difference_type;
>    using iterator_category = std::forward_iterator_tag;
> +  using iterator_concept = std::forward_iterator_tag;
>
>    /// Construct the iterator based on a pair of underlying iterators and a
>    /// symtab_filter object. Immediately fast forward to the next element that
> --
> 2.41.0.rc0.172.g3f132b7071-goog
>
  
Dodji Seketeli June 7, 2023, 2:46 p.m. UTC | #2
"Matthias Männich" <maennich@google.com> a écrit:

> From: Matthias Maennich <maennich@google.com>
>
> Inheriting from std::vector::iterator causes the type to advertise
> itself as a contiguous iterator. This causes a compilation error in
> newer versions of libc++ that try to use contiguous-iterator-specific
> optimizations in those situations. Fixed thus by explicitly specifying
> the interator_concept tag.
>
> 	* abg-symtab-reader.h (symtab_iterator): Specify
> 	  iterator_concept as forward_iterator to support C++20 compilation.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>

Applied to master, thanks!

[...]

Cheers,
  

Patch

diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h
index 7477cca5a6f0..888a56822224 100644
--- a/src/abg-symtab-reader.h
+++ b/src/abg-symtab-reader.h
@@ -115,6 +115,7 @@  public:
   using pointer = base_iterator::pointer;
   using difference_type = base_iterator::difference_type;
   using iterator_category = std::forward_iterator_tag;
+  using iterator_concept = std::forward_iterator_tag;
 
   /// Construct the iterator based on a pair of underlying iterators and a
   /// symtab_filter object. Immediately fast forward to the next element that