bugGNU gettext - Bugs: bug #35313, autosprintf.h breaks standard...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #35313: autosprintf.h breaks standard headers with -std=c++(98|0x)

Submitter:  None
Submitted:  Sun 15 Jan 2012 12:50:38 PM UTC
   
 
Category:  Programmer interface Severity:  3 - Normal
Item Group:  None Status:  Fix Released
Privacy:  Public Assigned to:  m1gu3l
Open/Closed:  Closed

Fri 08 Mar 2013 09:12:32 AM UTC, comment #3: 

Miguel's patch pushed.

Daiki Ueno <ueno>
Group administrator
Fri 01 Mar 2013 08:12:06 PM UTC, comment #2: 
Miguel Ángel Arruga Vivas <m1gu3l>
Group Member
Tue 29 Jan 2013 06:26:32 PM UTC, comment #1: 

http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html

Also, a header included below autosprintf.h  or even the code may want to use the compiler "__attribute__" , not the autosprintf.h definition.

Miguel Ángel Arruga Vivas <m1gu3l>
Group Member
Sun 15 Jan 2012 12:50:38 PM UTC, original submission:  

The following piece of code:
-----8<-----
#include <autosprintf.h>
int main() {return 0;}
----->8-----

compiled with:
$ g++ -std=c++98 -Wall -Werror foo.cc

yields the following warnings (which got turned into errors):
-----8<-----
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:118:1: error: ‘int __gthrw_pthread_once(pthread_once_t*, void (*)())’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:119:1: error: ‘void* __gthrw_pthread_getspecific(pthread_key_t) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:120:1: error: ‘int __gthrw_pthread_setspecific(pthread_key_t, const void*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:122:1: error: ‘int __gthrw_pthread_create(pthread_t*, const pthread_attr_t*, void* ()(void), void*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:123:1: error: ‘int __gthrw_pthread_join(pthread_t, void**)’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:124:1: error: ‘int __gthrw_pthread_equal(pthread_t, pthread_t) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:125:1: error: ‘pthread_t __gthrw_pthread_self() throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:126:1: error: ‘int __gthrw_pthread_detach(pthread_t) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:128:1: error: ‘int __gthrw_pthread_cancel(pthread_t)’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:130:1: error: ‘int __gthrw_sched_yield() throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:132:1: error: ‘int __gthrw_pthread_mutex_lock(pthread_mutex_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:133:1: error: ‘int __gthrw_pthread_mutex_trylock(pthread_mutex_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:136:1: error: ‘int __gthrw_pthread_mutex_timedlock(pthread_mutex_t*, const timespec*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:139:1: error: ‘int __gthrw_pthread_mutex_unlock(pthread_mutex_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:140:1: error: ‘int __gthrw_pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:141:1: error: ‘int __gthrw_pthread_mutex_destroy(pthread_mutex_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:143:1: error: ‘int __gthrw_pthread_cond_broadcast(pthread_cond_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:144:1: error: ‘int __gthrw_pthread_cond_signal(pthread_cond_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:145:1: error: ‘int __gthrw_pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*)’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:146:1: error: ‘int __gthrw_pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const timespec*)’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:147:1: error: ‘int __gthrw_pthread_cond_destroy(pthread_cond_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:150:1: error: ‘int __gthrw_pthread_key_create(pthread_key_t*, void ()(void)) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:151:1: error: ‘int __gthrw_pthread_key_delete(pthread_key_t) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:152:1: error: ‘int __gthrw_pthread_mutexattr_init(pthread_mutexattr_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:153:1: error: ‘int __gthrw_pthread_mutexattr_settype(pthread_mutexattr_t*, int) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:154:1: error: ‘int __gthrw_pthread_mutexattr_destroy(pthread_mutexattr_t*) throw ()’ declared ‘static’ but never defined [-Werror=unused-function]
cc1plus: all warnings being treated as errors
----->8-----

A quick workaround is:
-----8<-----
--- foo.cc      2012-01-15 20:33:04.514366708 +0800
+++ foo.new.cc  2012-01-15 20:35:37.518592500 +0800
@@ -1,2 +1,4 @@
+#include <iostream>
+#include <string>
 #include <autosprintf.h>
 int main () {return 0;}
----->8-----

As for why it's happening: autosprintf.h has the following snippet of code which breaks _attribute_ which is used internally by libstdc++.
-----8<-----
#ifndef _attribute_
/* This feature is available in gcc versions 2.5 and later.  */
# if _GNUC_ < 2 || (_GNUC_ == 2 && _GNUC_MINOR_ < 5) || _STRICT_ANSI_
#  define _attribute_(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
# if _GNUC_ < 2 || (_GNUC_ == 2 && _GNUC_MINOR_ < 7)
#  define _format_ format
#  define _printf_ printf
# endif
#endif
----->8-----

The attached patch fixes the issue.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Updated the item)
  • -email is unavailable- added by ueno (Posted a comment)
  • -email is unavailable- added by m1gu3l (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-04 haible StatusFixed Fix Released
    2016-11-27 haible CategoryNone Programmer interface
    2013-03-08 ueno StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-03-01 m1gu3l StatusIn Progress Ready For Test
    2013-02-28 m1gu3l StatusNone In Progress
        Assigned toNone m1gu3l
    2012-01-15 None Attached File- Added 0001-Fix-__attribute__-breakage-with-__STRICT_ANSI__.patch, #24826

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code