[libstdc++] Fix some header warnings

Jakub Jelinek jakub@redhat.com
Mon Dec 10 09:56:00 GMT 2007


On Mon, Dec 10, 2007 at 10:17:07AM +0100, Paolo Carlini wrote:
> Hi,
> > This patch just fixes 4 of them in installed headers -
> > ref.second.{first,second} is size_t, so ideally we'd use %zu, but I'm afraid
> > there are lame targets around that don't support %zu.  Casting to long and
> > %lu should be good and portable enough.  Alternatively, perhaps s += ref.second.first;
> > could work too, but that's what the code contained originally and was
> > changed to sprintf a year ago or so.
> >   
> That's weird, it would be nice if Benjamin could comment. Otherwise,
> let's just go ahead with your patch, for now at least.

Ok, will wait for Benjamin to comment on this ;)

> > The second file changes are just to shut up warning about using
> > x && y || a && b without parens.
> >   
> This hunk is obviously correct. By the way, installed headers should
> have the warning suppressed by the effect of the system header pragma
> (in mainline we also have Tom Tromey' recent patch fixing the pragma)...
> Or??

Yeah, they are surpressed when used with -isystem, but probably that's
not the case when compiling the testsuite with -Wall.

> At some point we should also look at the other 68 warnings in the
> testsuite... I bet most are trivial, still annoying.

Sure, most of them really look trivial, though I'm afraid I don't have
time to tackle them all...

Below are all the warnings (sort -u'ed) I got on x86_64, of course to fix them
some context (for headers which test, included from where, etc.) is usually needed.

libstdc++-v3/include/bits/basic_string.h:1467: warning: array subscript is above array boundslibstdc++-v3/include/bits/basic_string.h:1467: warning: array subscript is above array bounds
libstdc++-v3/include/bits/codecvt.h:126: warning: array subscript is above array bounds
libstdc++-v3/include/bits/codecvt.h:206: warning: array subscript is above array bounds
libstdc++-v3/include/bits/codecvt.h:220: warning: array subscript is above array bounds
libstdc++-v3/include/bits/stl_algo.h:4573: warning: 'r$value' is used uninitialized in this function
libstdc++-v3/include/bits/stl_algo.h:4598: warning: 'r$value' is used uninitialized in this function
libstdc++-v3/include/debug/safe_iterator.tcc:58: warning: suggest parentheses around && within ||
libstdc++-v3/include/debug/safe_iterator.tcc:68: warning: suggest parentheses around && within ||
libstdc++-v3/include/ext/throw_allocator.h:437: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
libstdc++-v3/include/ext/throw_allocator.h:441: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
libstdc++-v3/include/tr1_impl/functional:531: warning: type qualifiers ignored on function return type
libstdc++-v3/testsuite/18_support/headers/cstddef/macros.cc:45: warning: unused variable 'j'
libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc:29: warning: unused variable 'b'
libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc:29: warning: unused variable 'i'
libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc:31: warning: unused variable 'l'
libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/22_locale/time_put/put/char/5.cc:56: warning: array subscript is above array bounds
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:103: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:108: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:113: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:118: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:123: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:51: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:56: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:61: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:66: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc:71: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:101: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:71: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:76: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:81: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:86: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:91: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc:96: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/23_containers/map/operations/1.cc:131: warning: ISO C++ forbids declaration of 'main' with no type
libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc:130: warning: ISO C++ forbids declaration of 'main' with no type
libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc:129: warning: ISO C++ forbids declaration of 'main' with no type
libstdc++-v3/testsuite/23_containers/set/operations/1.cc:130: warning: ISO C++ forbids declaration of 'main' with no type
libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/25_algorithms/nth_element/2.cc:59: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc:46: warning: unused variable 'b'
libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/pod/3983-2.cc:54: warning: missing braces around initializer for '__gnu_test::pod_ushort'
libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/12296.cc:33: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc:41: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-2.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-3.cc:41: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-4.cc:42: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc:109: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc:111: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc:113: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/sbumpc/wchar_t/1.cc:50: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/sbumpc/wchar_t/1.cc:51: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/sgetn/wchar_t/1.cc:86: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/sgetn/wchar_t/1.cc:87: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/snextc/wchar_t/1.cc:65: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/27_io/basic_stringbuf/snextc/wchar_t/1.cc:66: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc:45: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_xref.cc:84: warning: type qualifiers ignored on function return type
libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc:41: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc:41: warning: comparison between signed and unsigned integer expressions
libstdc++-v3/testsuite/thread/guard.cc:43: warning: unused variable 'bar'
libstdc++-v3/testsuite/thread/guard.cc:50: warning: unused variable 'status'
libstdc++-v3/testsuite/thread/guard.cc:65: warning: unused variable 'foo'
libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc:165: warning: unused variable 'ret'
libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc:167: warning: unused variable 'ret'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/linear_congruential/requirements/non_uint_neg.cc:37: warning: unused variable 'x'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/random_device/cons/default.cc:33: warning: 'x.std::tr1::random_device::_M_file' may be used uninitialized in this function
libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/random_device/cons/token.cc:34: warning: 'x.std::tr1::random_device::_M_file' may be used uninitialized in this function
libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/uniform_int/33128.cc:37: warning: control reaches end of non-void function
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/compile.cc:36: warning: unused variable 'a'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/compile.cc:37: warning: unused variable 'b'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/compile.cc:38: warning: unused variable 'c'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/compile.cc:39: warning: unused variable 'd'
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/compile.cc:40: warning: unused variable 'e'
libstdc++-v3/testsuite/tr1/6_containers/array/capacity/empty.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/capacity/max_size.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/capacity/size.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/back.cc:35: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/back.cc:41: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/data.cc:35: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/data.cc:41: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/front.cc:35: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/element_access/front.cc:41: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc:33: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc:34: warning: missing braces around initializer for 'int [3]'
libstdc++-v3/testsuite/tr1/6_containers/array/requirements/contiguous.cc:32: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc:37: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc:34: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc:37: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/get.cc:36: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/get.cc:42: warning: missing braces around initializer for 'int [5]'
libstdc++-v3/testsuite/tr1/6_containers/hash/operators/size_t.cc:39: warning: 'v' is used uninitialized in this function
libstdc++-v3/testsuite/tr1/6_containers/tuple/cons/big_tuples.cc:40: warning: unused variable 'ta'
libstdc++-v3/testsuite/tr1/6_containers/tuple/cons/constructor.cc:36: warning: unused variable 'ta'
libstdc++-v3/testsuite/util/testsuite_hooks.cc:176: warning: unused variable 'test'
libstdc++-v3/testsuite/util/testsuite_hooks.cc:205: warning: unused variable 'test'
libstdc++-v3/testsuite/util/testsuite_rvalref.h:148: warning: no return statement in function returning non-void
libstdc++-v3/testsuite/util/testsuite_rvalref.h:157: warning: control reaches end of non-void function
libstdc++-v3/testsuite/util/testsuite_rvalref.h:75: warning: control reaches end of non-void function

	Jakub



More information about the Gcc-patches mailing list