GNU bug report logs - #11829
Build failure with --enable-gcc-warnings

Previous Next

Package: coreutils;

Reported by: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Date: Sat, 30 Jun 2012 22:28:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11829 in the body.
You can then email your comments to 11829 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#11829; Package coreutils. (Sat, 30 Jun 2012 22:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefano Lattarini <stefano.lattarini <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 30 Jun 2012 22:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Build failure with --enable-gcc-warnings
Date: Sun, 01 Jul 2012 00:22:22 +0200
Trying to build the latest coreutils from master:

  $ make all
  ...
    CC       stty.o
  stty.c: In function 'main':
  stty.c:740:8: error: variable 'speed_was_set' set but not used [-Werror=unused-but-set-variable]
  cc1: all warnings being treated as errors
  make[3]: *** [stty.o] Error 1

  $ uname -rmos
  Linux 3.3.1-3.fc16.ppc64 ppc64 GNU/Linux

  $ gcc --version
  gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)
  Copyright (C) 2011 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Let me know if you need more information.

Regards,
  Stefano




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Sat, 30 Jun 2012 23:16:02 GMT) Full text and rfc822 format available.

Notification sent to Stefano Lattarini <stefano.lattarini <at> gmail.com>:
bug acknowledged by developer. (Sat, 30 Jun 2012 23:16:02 GMT) Full text and rfc822 format available.

Message #10 received at 11829-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 11829-done <at> debbugs.gnu.org
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Sun, 01 Jul 2012 00:10:41 +0100
On 06/30/2012 11:22 PM, Stefano Lattarini wrote:
> Trying to build the latest coreutils from master:
> 
>   $ make all
>   ...
>     CC       stty.o
>   stty.c: In function 'main':
>   stty.c:740:8: error: variable 'speed_was_set' set but not used [-Werror=unused-but-set-variable]
>   cc1: all warnings being treated as errors
>   make[3]: *** [stty.o] Error 1
> 
>   $ uname -rmos
>   Linux 3.3.1-3.fc16.ppc64 ppc64 GNU/Linux
> 
>   $ gcc --version
>   gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)
>   Copyright (C) 2011 Free Software Foundation, Inc.
>   This is free software; see the source for copying conditions.  There is NO
>   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> Let me know if you need more information.

This should address it:

commit 8f4dcad477da1a952a04478ae125d5453f29dcc9
Author: Pádraig Brady <P <at> draigBrady.com>
Date:   Sun Jul 1 00:04:37 2012 +0100

    maint: avoid a -Wunsed-but-set warning on some systems

    * src/stty.c (main): Mark speed_was_set as unused when
    CIBAUD undefined (like on ppc64 GNU/Linux for example).
    Reported-by: Stefano Lattarini

diff --git a/src/stty.c b/src/stty.c
index 83b502c..b2dd849 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -737,7 +737,11 @@ main (int argc, char **argv)
   int argi = 0;
   int opti = 1;
   bool require_set_attr;
+#ifdef CIBAUD
   bool speed_was_set;
+#else
+  bool speed_was_set ATTRIBUTE_UNUSED;
+#endif
   bool verbose_output;
   bool recoverable_output;
   int k;





Information forwarded to bug-coreutils <at> gnu.org:
bug#11829; Package coreutils. (Sat, 30 Jun 2012 23:43:02 GMT) Full text and rfc822 format available.

Message #13 received at 11829 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: 11829 <at> debbugs.gnu.org, P <at> draigBrady.com
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Sat, 30 Jun 2012 17:38:12 -0600
[Message part 1 (text/plain, inline)]
On 06/30/2012 05:10 PM, Pádraig Brady wrote:

> This should address it:
> 
> commit 8f4dcad477da1a952a04478ae125d5453f29dcc9
> Author: Pádraig Brady <P <at> draigBrady.com>
> Date:   Sun Jul 1 00:04:37 2012 +0100
> 
>     maint: avoid a -Wunsed-but-set warning on some systems
> 
>     * src/stty.c (main): Mark speed_was_set as unused when
>     CIBAUD undefined (like on ppc64 GNU/Linux for example).
>     Reported-by: Stefano Lattarini
> 
> diff --git a/src/stty.c b/src/stty.c
> index 83b502c..b2dd849 100644
> --- a/src/stty.c
> +++ b/src/stty.c
> @@ -737,7 +737,11 @@ main (int argc, char **argv)
>    int argi = 0;
>    int opti = 1;
>    bool require_set_attr;
> +#ifdef CIBAUD
>    bool speed_was_set;
> +#else
> +  bool speed_was_set ATTRIBUTE_UNUSED;
> +#endif

Three lines too many.  ATTRIBUTE_UNUSED is defined by gcc to mean 'might
be unused, therefore don't warn if it was not used', and not 'must not
be used, and therefore warn if it is used'.  Therefore, it is always
safe to use the one-liner:

bool speed_was_set ATTRIBUTE_UNUSED;

even if, when CIBAUD is defined, it was actually used.  No need for
extra #ifdef.

-- 
Eric Blake   eblake <at> redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#11829; Package coreutils. (Sat, 30 Jun 2012 23:52:01 GMT) Full text and rfc822 format available.

Message #16 received at 11829 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 11829 <at> debbugs.gnu.org
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Sun, 01 Jul 2012 00:47:02 +0100
On 07/01/2012 12:38 AM, Eric Blake wrote:
> On 06/30/2012 05:10 PM, Pádraig Brady wrote:
> 
>> This should address it:
>>
>> commit 8f4dcad477da1a952a04478ae125d5453f29dcc9
>> Author: Pádraig Brady <P <at> draigBrady.com>
>> Date:   Sun Jul 1 00:04:37 2012 +0100
>>
>>     maint: avoid a -Wunsed-but-set warning on some systems
>>
>>     * src/stty.c (main): Mark speed_was_set as unused when
>>     CIBAUD undefined (like on ppc64 GNU/Linux for example).
>>     Reported-by: Stefano Lattarini
>>
>> diff --git a/src/stty.c b/src/stty.c
>> index 83b502c..b2dd849 100644
>> --- a/src/stty.c
>> +++ b/src/stty.c
>> @@ -737,7 +737,11 @@ main (int argc, char **argv)
>>    int argi = 0;
>>    int opti = 1;
>>    bool require_set_attr;
>> +#ifdef CIBAUD
>>    bool speed_was_set;
>> +#else
>> +  bool speed_was_set ATTRIBUTE_UNUSED;
>> +#endif
> 
> Three lines too many.  ATTRIBUTE_UNUSED is defined by gcc to mean 'might
> be unused, therefore don't warn if it was not used', and not 'must not
> be used, and therefore warn if it is used'.  Therefore, it is always
> safe to use the one-liner:
> 
> bool speed_was_set ATTRIBUTE_UNUSED;
> 
> even if, when CIBAUD is defined, it was actually used.  No need for
> extra #ifdef.
> 

But then you would never get such warnings for this variable.
I was trying to disable the warning only where it's incorrect,
and thought the single ifdef worth it?




Information forwarded to bug-coreutils <at> gnu.org:
bug#11829; Package coreutils. (Sat, 30 Jun 2012 23:59:02 GMT) Full text and rfc822 format available.

Message #19 received at 11829 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 11829 <at> debbugs.gnu.org
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Sat, 30 Jun 2012 17:53:51 -0600
[Message part 1 (text/plain, inline)]
On 06/30/2012 05:47 PM, Pádraig Brady wrote:

>>> +#ifdef CIBAUD
>>>    bool speed_was_set;
>>> +#else
>>> +  bool speed_was_set ATTRIBUTE_UNUSED;
>>> +#endif
>>
>> Three lines too many.  ATTRIBUTE_UNUSED is defined by gcc to mean 'might
>> be unused, therefore don't warn if it was not used', and not 'must not
>> be used, and therefore warn if it is used'.  Therefore, it is always
>> safe to use the one-liner:
>>
>> bool speed_was_set ATTRIBUTE_UNUSED;
>>
>> even if, when CIBAUD is defined, it was actually used.  No need for
>> extra #ifdef.
>>
> 
> But then you would never get such warnings for this variable.
> I was trying to disable the warning only where it's incorrect,
> and thought the single ifdef worth it?

My point is that there ARE no warnings if you unconditionally use the
label.  That is, gcc behaves the same with no warnings, on both the case
where CIBAUD is undefined and where it is defined, given either:

#ifdef CIBAUD
  bool speed_was_set;
#else
  bool speed_was_set ATTRIBUTE_UNUSED;
#endif
...
#ifdef CIBAUD
  use(speed_was_set);
#endif

or whether you use the shorter:

  bool speed_was_set ATTRIBUTE_UNUSED;
...
#ifdef CIBAUD
  use(speed_was_set);
#endif

and that's because the definition of ATTRIBUTE_UNUSED in gcc means only
"this _might_ be unused on some conditional compilations, so suppress
unused warnings".

Had gcc defined ATTRIBUTE_UNUSED as "warn if we used it after all", then
yes, you'd need the #ifdef.  Thankfully, gcc did not use that formulation.

-- 
Eric Blake   eblake <at> redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Message #20 received at 11829-done <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 11829-done <at> debbugs.gnu.org
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Sun, 01 Jul 2012 10:00:49 +0200
On 07/01/2012 01:10 AM, Pádraig Brady wrote:
> On 06/30/2012 11:22 PM, Stefano Lattarini wrote:
>> Trying to build the latest coreutils from master:
>>
>>   $ make all
>>   ...
>>     CC       stty.o
>>   stty.c: In function 'main':
>>   stty.c:740:8: error: variable 'speed_was_set' set but not used [-Werror=unused-but-set-variable]
>>   cc1: all warnings being treated as errors
>>   make[3]: *** [stty.o] Error 1
>>
>>   $ uname -rmos
>>   Linux 3.3.1-3.fc16.ppc64 ppc64 GNU/Linux
>>
>>   $ gcc --version
>>   gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)
>>   Copyright (C) 2011 Free Software Foundation, Inc.
>>   This is free software; see the source for copying conditions.  There is NO
>>   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
>> Let me know if you need more information.
> 
> This should address it:
> 
> commit 8f4dcad477da1a952a04478ae125d5453f29dcc9
> Author: Pádraig Brady <P <at> draigBrady.com>
> Date:   Sun Jul 1 00:04:37 2012 +0100
> 
>     maint: avoid a -Wunsed-but-set warning on some systems
> 
>     * src/stty.c (main): Mark speed_was_set as unused when
>     CIBAUD undefined (like on ppc64 GNU/Linux for example).
>     Reported-by: Stefano Lattarini
> 
> diff --git a/src/stty.c b/src/stty.c
> index 83b502c..b2dd849 100644
> --- a/src/stty.c
> +++ b/src/stty.c
> @@ -737,7 +737,11 @@ main (int argc, char **argv)
>    int argi = 0;
>    int opti = 1;
>    bool require_set_attr;
> +#ifdef CIBAUD
>    bool speed_was_set;
> +#else
> +  bool speed_was_set ATTRIBUTE_UNUSED;
> +#endif
>    bool verbose_output;
>    bool recoverable_output;
>    int k;
> 
I can confirm this solves the problem for me.

Thanks,
  Stefano




Message #21 received at 11829-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 11829-done <at> debbugs.gnu.org
Subject: Re: bug#11829: Build failure with --enable-gcc-warnings
Date: Mon, 02 Jul 2012 12:32:58 +0200
On 07/01/2012 01:53 AM, Eric Blake wrote:
> On 06/30/2012 05:47 PM, Pádraig Brady wrote:
> 
>>>> +#ifdef CIBAUD
>>>>    bool speed_was_set;
>>>> +#else
>>>> +  bool speed_was_set ATTRIBUTE_UNUSED;
>>>> +#endif
>>>
>>> Three lines too many.  ATTRIBUTE_UNUSED is defined by gcc to mean 'might
>>> be unused, therefore don't warn if it was not used', and not 'must not
>>> be used, and therefore warn if it is used'.  Therefore, it is always
>>> safe to use the one-liner:
>>>
>>> bool speed_was_set ATTRIBUTE_UNUSED;
>>>
>>> even if, when CIBAUD is defined, it was actually used.  No need for
>>> extra #ifdef.
>>>
>>
>> But then you would never get such warnings for this variable.
>> I was trying to disable the warning only where it's incorrect,
>> and thought the single ifdef worth it?
> 
> My point is that there ARE no warnings if you unconditionally use the
> label.

Sure.
But my version leaves the warning enabled in more cases.
But the extra ifdef is probably not worth it,
so I'll remove it.

cheers,
Pádraig.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 30 Jul 2012 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.