abg-leaf-reporter.cc: Fix build with gcc 4.9.

Message ID 20240612205912.97-1-romain.geissler@amadeus.com
State New
Headers
Series abg-leaf-reporter.cc: Fix build with gcc 4.9. |

Commit Message

Romain Geissler June 12, 2024, 8:59 p.m. UTC
  Hi Dodji,

FYI I am having a small build error when building with gcc 4.9 (yes
unfortunately we still have cases where we use such an old toolchain):

/workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc: In member function 'virtual void abigail::comparison::leaf_reporter::report(const abigail::comparison::corpus_diff&, std::ostream&, const string&) const':
/workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc:1311:21: error: use of 'd' before deduction of 'auto'
       for (auto d : d.priv_->sorted_changed_vars_)

This patch slightly changes the code to avoid this shadowing case, a use
of auto, and IMO actually makes the code simpler. Is it ok to apply ?

Cheers,
Romain


abg-leaf-reporter.cc: Fix build with gcc 4.9.

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
---
 src/abg-leaf-reporter.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Dodji Seketeli June 18, 2024, 4:25 p.m. UTC | #1
Hello Romain,

Sorry for my late reply, I was on the road.

Romain Geissler <romain.geissler@amadeus.com> a écrit:

> Hi Dodji,
>
> FYI I am having a small build error when building with gcc 4.9 (yes
> unfortunately we still have cases where we use such an old toolchain):
>
> /workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc: In member function 'virtual void abigail::comparison::leaf_reporter::report(const abigail::comparison::corpus_diff&, std::ostream&, const string&) const':
> /workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc:1311:21: error: use of 'd' before deduction of 'auto'
>        for (auto d : d.priv_->sorted_changed_vars_)
>
> This patch slightly changes the code to avoid this shadowing case, a use
> of auto, and IMO actually makes the code simpler. Is it ok to apply ?

Yes, of course, the patch looks quite trivial.  Many thanks for putting
it together.  I have just added the "required" (boring) ChangeLog part
to it.  It now looks like:

    From 9a48f1296154d8f6d5333308f6b2649b6bf55934 Mon Sep 17 00:00:00 2001
    From: Romain Geissler <romain.geissler@amadeus.com>
    Date: Wed, 12 Jun 2024 20:59:12 +0000
    Subject: [PATCH] abg-leaf-reporter.cc: Fix build with gcc 4.9.

            * src/abg-leaf-reporter.cc (leaf_reporter::report): In the
            overload for corpus_diff, avoid using auto type deduction in
            for-each loop.

    Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
    Signed-off-by: Dodji Seketeli <dodji@redhat.com>
    ---
     src/abg-leaf-reporter.cc | 4 +---
     1 file changed, 1 insertion(+), 3 deletions(-)

    diff --git a/src/abg-leaf-reporter.cc b/src/abg-leaf-reporter.cc
    index 3b951505..1779bdb1 100644
    --- a/src/abg-leaf-reporter.cc
    +++ b/src/abg-leaf-reporter.cc
    @@ -1308,10 +1308,8 @@ leaf_reporter::report(const corpus_diff& d,
            out << indent << num_changed
                << " Changed variables:\n\n";
           string n1, n2;
    -      for (auto d : d.priv_->sorted_changed_vars_)
    +      for (diff_sptr diff : d.priv_->sorted_changed_vars_)
            {
    -	  diff_sptr diff = d;
    -
              if (!diff)
                continue;

    -- 
    2.43.0

I am currently running it through the CI builders using the branch
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/try-patches.
When the builders are done, you should receive an email.  In the mean
time, you can track their progress at
https://builder.sourceware.org/buildbot/#/builders?tags=%2Blibabigail-try.

When that's done, I'll apply the patch.

Thanks again!

[...]

Cheers,
  
Dodji Seketeli June 19, 2024, 9:46 a.m. UTC | #2
Hello,

Dodji Seketeli <dodji@seketeli.org> a écrit:

> Hello Romain,
>
> Sorry for my late reply, I was on the road.
>
> Romain Geissler <romain.geissler@amadeus.com> a écrit:
>
>> Hi Dodji,
>>
>> FYI I am having a small build error when building with gcc 4.9 (yes
>> unfortunately we still have cases where we use such an old toolchain):
>>
>> /workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc: In member function 'virtual void abigail::comparison::leaf_reporter::report(const abigail::comparison::corpus_diff&, std::ostream&, const string&) const':
>> /workdir/src/libabigail-2.5/src/abg-leaf-reporter.cc:1311:21: error: use of 'd' before deduction of 'auto'
>>        for (auto d : d.priv_->sorted_changed_vars_)
>>
>> This patch slightly changes the code to avoid this shadowing case, a use
>> of auto, and IMO actually makes the code simpler. Is it ok to apply ?
>
> Yes, of course, the patch looks quite trivial.  Many thanks for putting
> it together.  I have just added the "required" (boring) ChangeLog part
> to it.  It now looks like:
>
>     From 9a48f1296154d8f6d5333308f6b2649b6bf55934 Mon Sep 17 00:00:00 2001
>     From: Romain Geissler <romain.geissler@amadeus.com>
>     Date: Wed, 12 Jun 2024 20:59:12 +0000
>     Subject: [PATCH] abg-leaf-reporter.cc: Fix build with gcc 4.9.
>
>             * src/abg-leaf-reporter.cc (leaf_reporter::report): In the
>             overload for corpus_diff, avoid using auto type deduction in
>             for-each loop.
>
>     Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
>     Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Pushed to the mainline branch at https://sourceware.org/git/?p=libabigail.git;a=commit;h=2b2fa6ff144dac78b11ddbbb2ae2185f0a670e18.

[...]

Cheers,
  

Patch

diff --git a/src/abg-leaf-reporter.cc b/src/abg-leaf-reporter.cc
index 3b951505..1779bdb1 100644
--- a/src/abg-leaf-reporter.cc
+++ b/src/abg-leaf-reporter.cc
@@ -1308,10 +1308,8 @@  leaf_reporter::report(const corpus_diff& d,
 	out << indent << num_changed
 	    << " Changed variables:\n\n";
       string n1, n2;
-      for (auto d : d.priv_->sorted_changed_vars_)
+      for (diff_sptr diff : d.priv_->sorted_changed_vars_)
 	{
-	  diff_sptr diff = d;
-
 	  if (!diff)
 	    continue;