threads / patch / 58570

patchgit-compat-util.h: GCC deprecated message arg only in GCC 4.5+

Subject: [PATCH] git-compat-util.h: GCC deprecated message arg only in GCC 4.5+

## tl;dr

4 messages between Oct 5, 2022 and Oct 6, 2022. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Aleajndro R Sedeño· Oct 5, 2022, 22:19 UTC · lore
From: Alejandro R. Sedeño <asedeno@mit.edu>
From: https://gcc.gnu.org/gcc-4.5/changes.html
> The deprecated attribute now takes an optional string argument, for
> example, __attribute__((deprecated("text string"))), that will be
> printed together with the deprecation warning.

While GCC 4.5 is already 12 years old, git checks for even older versions in places. Let's not needlessly break older compilers when a small and simple fix is readily available.

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
---
 git-compat-util.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Show changes to git-compat-util.h +4 −1
diff --git a/git-compat-util.h b/git-compat-util.h
index b90b64718e..045b47f83a 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -189,9 +189,12 @@ struct strbuf;
 #define _NETBSD_SOURCE 1
 #define _SGI_SOURCE 1
 
-#if defined(__GNUC__)
+#if GIT_GNUC_PREREQ(4, 5)
 #define UNUSED __attribute__((unused)) \
 	__attribute__((deprecated ("parameter declared as UNUSED")))
+#elif defined(__GNUC__)
+#define UNUSED __attribute__((unused)) \
+	__attribute__((deprecated))
 #else
 #define UNUSED
 #endif
-- 
2.38.0.rc1.362.ged0d419d3c-goog
Ævar Arnfjörð Bjarmason· Oct 6, 2022, 07:31 UTC · re: Aleajndro R Sedeño · lore

Re: [PATCH] git-compat-util.h: GCC deprecated message arg only in GCC 4.5+

On Wed, Oct 05 2022, Aleajndro R Sedeño wrote:
Show 36 quoted lines
> From: Alejandro R. Sedeño <asedeno@mit.edu>
>
> From: https://gcc.gnu.org/gcc-4.5/changes.html
>
>> The deprecated attribute now takes an optional string argument, for
>> example, __attribute__((deprecated("text string"))), that will be
>> printed together with the deprecation warning.
>
> While GCC 4.5 is already 12 years old, git checks for even older
> versions in places. Let's not needlessly break older compilers when
> a small and simple fix is readily available.
>
> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
> Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
> ---
>  git-compat-util.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index b90b64718e..045b47f83a 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -189,9 +189,12 @@ struct strbuf;
>  #define _NETBSD_SOURCE 1
>  #define _SGI_SOURCE 1
>  
> -#if defined(__GNUC__)
> +#if GIT_GNUC_PREREQ(4, 5)
>  #define UNUSED __attribute__((unused)) \
>  	__attribute__((deprecated ("parameter declared as UNUSED")))
> +#elif defined(__GNUC__)
> +#define UNUSED __attribute__((unused)) \
> +	__attribute__((deprecated))
>  #else
>  #define UNUSED
>  #endif

This LGTM, thanks a lot for that fix & fixing this (minor) breakage of mine.

I did test on an older GCC myself, and then (in lieu of logging into an ancient system I have access to) scoured the release notes of gcc, and discovered that "deprecated" was older than anything we cared about.

But I obviously missed that while the feature had been there for a longer time, it didn't take this parameter until GCC 4.5, sorry!

Alejandro R. Sedeño· Oct 6, 2022, 12:24 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH] git-compat-util.h: GCC deprecated message arg only in GCC 4.5+

Happy to do so! I build new versions of git on a few systems as they roll out, and you'll find many of my (not that many) patches involve breakage on this particularly old system. I'm sure one day a big change will break git for good there, but in the meantime I'll do what I can to keep it going. :-)

-Alejandro
On Thu, Oct 6, 2022 at 3:33 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 50 quoted lines
>
>
> On Wed, Oct 05 2022, Aleajndro R Sedeño wrote:
>
> > From: Alejandro R. Sedeño <asedeno@mit.edu>
> >
> > From: https://gcc.gnu.org/gcc-4.5/changes.html
> >
> >> The deprecated attribute now takes an optional string argument, for
> >> example, __attribute__((deprecated("text string"))), that will be
> >> printed together with the deprecation warning.
> >
> > While GCC 4.5 is already 12 years old, git checks for even older
> > versions in places. Let's not needlessly break older compilers when
> > a small and simple fix is readily available.
> >
> > Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
> > Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
> > ---
> >  git-compat-util.h | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/git-compat-util.h b/git-compat-util.h
> > index b90b64718e..045b47f83a 100644
> > --- a/git-compat-util.h
> > +++ b/git-compat-util.h
> > @@ -189,9 +189,12 @@ struct strbuf;
> >  #define _NETBSD_SOURCE 1
> >  #define _SGI_SOURCE 1
> >
> > -#if defined(__GNUC__)
> > +#if GIT_GNUC_PREREQ(4, 5)
> >  #define UNUSED __attribute__((unused)) \
> >       __attribute__((deprecated ("parameter declared as UNUSED")))
> > +#elif defined(__GNUC__)
> > +#define UNUSED __attribute__((unused)) \
> > +     __attribute__((deprecated))
> >  #else
> >  #define UNUSED
> >  #endif
>
> This LGTM, thanks a lot for that fix & fixing this (minor) breakage of
> mine.
>
> I did test on an older GCC myself, and then (in lieu of logging into an
> ancient system I have access to) scoured the release notes of gcc, and
> discovered that "deprecated" was older than anything we cared about.
>
> But I obviously missed that while the feature had been there for a
> longer time, it didn't take this parameter until GCC 4.5, sorry!
Alejandro R. Sedeño· Oct 5, 2022, 22:22 UTC · lore

Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+

Sorry for the subject line change; I had hoped that --in-reply-to would get it threaded properly and wanted to trim it down a bit.

-> "[PATCH] git-compat-util.h: GCC deprecated message arg only in GCC 4.5+"
-Alejandro
On Wed, Oct 5, 2022 at 5:59 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
>
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>
> > On 2022-10-03 at 21:23:18, Aleajndro R Sedeño wrote:
> >> From: Alejandro R. Sedeño <asedeno@mit.edu>
> >>
> >> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
> >> Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
> >
> > It might be helpful to explain what system you're targeting when you see
> > this.  CentOS 7 has GCC 4.8, and I'm not aware of any systems with an
> > older compiler receiving publicly available updates still.  We've fairly
> > recently only been testing and targeting GCC 4.8 for that reason.
>
> I do agree with you that an update to give "why" in the proposed log
> message would be very welcome, e.g. "Even though such an ancient
> compiler may not matter much in real life, a workaround is simple
> enough." or something along that line.
>
> As to the change in the patch, I think it is good.
>
> Thanks, all.  Expecting an updated version which hopefully would
> become the final version ;-)
>
>

← back to recent threads