In Oneiric, 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-----
Upstream bug at https:/ /savannah. gnu.org/ bugs/index. php?35313