https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063
Bug ID: 96063
Summary: mismatched-tags warnings in stdlib headers
Product: gcc
Version: 10.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: ian.s.mcinerney at ieee dot org
Target Milestone: ---
There are several places in the library headers where warnings can be emitted
for mismatched-tags (this was found when a mingw g++ compile misbehaved and
printed warnings for system headers for some reason). I am still not sure why
the compiler decided to throw the errors in the first place, but these seem
like something that can be cleaned up.
Warnings from building a C++ file that just includes all the headers:
In file included from /usr/include/c++/10/bits/ios_base.h:46,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from main.cpp:7:
/usr/include/c++/10/system_error:54:9: warning: ‘std::error_code’ declared with
a mismatched class-key ‘class’ [-Wmismatched-tags]
54 | class error_code;
| ^~~~~~~~~~
/usr/include/c++/10/system_error:54:9: note: replace the class-key with
‘struct’
/usr/include/c++/10/system_error:180:10: note: ‘std::error_code’ defined as
‘struct’ here
180 | struct error_code
| ^~~~~~~~~~
/usr/include/c++/10/system_error:55:9: warning: ‘std::error_condition’ declared
with a mismatched class-key ‘class’ [-Wmismatched-tags]
55 | class error_condition;
| ^~~~~~~~~~~~~~~
/usr/include/c++/10/system_error:55:9: note: replace the class-key with
‘struct’
/usr/include/c++/10/system_error:278:10: note: ‘std::error_condition’ defined
as ‘struct’ here
278 | struct error_condition
| ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/string:43,
from /usr/include/c++/10/bitset:47,
from main.cpp:6:
/usr/include/c++/10/bits/localefwd.h:125:9: warning: ‘std::ctype_base’ declared
with a mismatched class-key ‘class’ [-Wmismatched-tags]
125 | class ctype_base;
| ^~~~~~~~~~
/usr/include/c++/10/bits/localefwd.h:125:9: note: replace the class-key with
‘struct’
In file included from /usr/include/c++/10/bits/locale_facets.h:41,
from /usr/include/c++/10/bits/basic_ios.h:37,
from /usr/include/c++/10/ios:44,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from main.cpp:7:
/usr/include/c++/10/x86_64-redhat-linux/bits/ctype_base.h:41:10: note:
‘std::ctype_base’ defined as ‘struct’ here
41 | struct ctype_base
| ^~~~~~~~~~
In file included from main.cpp:7:
/usr/include/c++/10/complex:67:32: warning: ‘std::complex<_Tp>’ declared with a
mismatched class-key ‘class’ [-Wmismatched-tags]
67 | template<typename _Tp> class complex;
| ^~~~~~~
/usr/include/c++/10/complex:67:32: note: replace the class-key with ‘struct’
/usr/include/c++/10/complex:127:12: note: ‘std::complex<_Tp>’ defined as
‘struct’ here
127 | struct complex
| ^~~~~~~
/usr/include/c++/10/complex:68:20: warning: ‘std::complex<float>’ declared with
a mismatched class-key ‘class’ [-Wmismatched-tags]
68 | template<> class complex<float>;
| ^~~~~~~~~~~~~~
/usr/include/c++/10/complex:68:20: note: replace the class-key with ‘struct’
/usr/include/c++/10/complex:1082:12: note: ‘std::complex<float>’ defined as
‘struct’ here
1082 | struct complex<float>
| ^~~~~~~~~~~~~~
/usr/include/c++/10/complex:69:20: warning: ‘std::complex<double>’ declared
with a mismatched class-key ‘class’ [-Wmismatched-tags]
69 | template<> class complex<double>;
| ^~~~~~~~~~~~~~~
/usr/include/c++/10/complex:69:20: note: replace the class-key with ‘struct’
/usr/include/c++/10/complex:1227:12: note: ‘std::complex<double>’ defined as
‘struct’ here
1227 | struct complex<double>
| ^~~~~~~~~~~~~~~
/usr/include/c++/10/complex:70:20: warning: ‘std::complex<long double>’
declared with a mismatched class-key ‘class’ [-Wmismatched-tags]
70 | template<> class complex<long double>;
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/complex:70:20: note: replace the class-key with ‘struct’
/usr/include/c++/10/complex:1372:12: note: ‘std::complex<long double>’ defined
as ‘struct’ here
1372 | struct complex<long double>
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/string:43,
from /usr/include/c++/10/bitset:47,
from main.cpp:6:
/usr/include/c++/10/bits/localefwd.h:203:9: warning: ‘std::messages_base’
declared with a mismatched class-key ‘class’ [-Wmismatched-tags]
203 | class messages_base;
| ^~~~~~~~~~~~~
/usr/include/c++/10/bits/localefwd.h:203:9: note: replace the class-key with
‘struct’
In file included from /usr/include/c++/10/locale:41,
from /usr/include/c++/10/iomanip:43,
from main.cpp:12:
/usr/include/c++/10/bits/locale_facets_nonio.h:1770:10: note:
‘std::messages_base’ defined as ‘struct’ here
1770 | struct messages_base
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/future:39,
from main.cpp:46:
/usr/include/c++/10/thread:100:20: warning: ‘std::hash<std::thread::id>’
declared with a mismatched class-key ‘class’ [-Wmismatched-tags]
100 | friend class hash<id>;
| ^~~~~~~~
/usr/include/c++/10/thread:100:20: note: replace the class-key with ‘struct’
/usr/include/c++/10/thread:338:12: note: ‘std::hash<std::thread::id>’ defined
as ‘struct’ here
338 | struct hash<thread::id>
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/regex:61,
from main.cpp:51:
/usr/include/c++/10/bits/regex_compiler.h:37:11: warning:
‘std::__cxx11::regex_traits< <template-parameter-1-1> >’ declared with a
mismatched class-key ‘class’ [-Wmismatched-tags]
37 | class regex_traits;
| ^~~~~~~~~~~~
/usr/include/c++/10/bits/regex_compiler.h:37:11: note: replace the class-key
with ‘struct’
In file included from /usr/include/c++/10/regex:62,
from main.cpp:51:
/usr/include/c++/10/bits/regex.h:80:12: note: ‘std::__cxx11::regex_traits<
<template-parameter-1-1> >’ defined as ‘struct’ here
80 | struct regex_traits
| ^~~~~~~~~~~~
In file included from main.cpp:35:
/usr/include/c++/10/valarray:574:20: warning: ‘std::_Array<_Tp>’ declared with
a mismatched class-key ‘class’ [-Wmismatched-tags]
574 | friend class _Array<_Tp>;
| ^~~~~~~~~~~
/usr/include/c++/10/valarray:574:20: note: replace the class-key with ‘struct’
In file included from /usr/include/c++/10/valarray:100,
from main.cpp:35:
/usr/include/c++/10/bits/valarray_array.h:396:12: note: ‘std::_Array<_Tp>’
defined as ‘struct’ here
396 | struct _Array
| ^~~~~~
In file included from main.cpp:46:
/usr/include/c++/10/future:1051:57: warning:
‘std::__future_base::_State_baseV2::_Setter<_Res, _Arg>’ declared with a
mismatched class-key ‘class’ [-Wmismatched-tags]
1051 | template<typename, typename> friend class _State::_Setter;
| ^~~~~~~
/usr/include/c++/10/future:1051:57: note: replace the class-key with ‘struct’
/usr/include/c++/10/future:462:16: note:
‘std::__future_base::_State_baseV2::_Setter<_Res, _Arg>’ first declared as
‘struct’ here
462 | struct _Setter;
| ^~~~~~~
/usr/include/c++/10/future:1162:57: warning:
‘std::__future_base::_State_baseV2::_Setter<_Res, _Arg>’ declared with a
mismatched class-key ‘class’ [-Wmismatched-tags]
1162 | template<typename, typename> friend class _State::_Setter;
| ^~~~~~~
/usr/include/c++/10/future:1162:57: note: replace the class-key with ‘struct’
/usr/include/c++/10/future:1252:57: warning:
‘std::__future_base::_State_baseV2::_Setter<_Res, _Arg>’ declared with a
mismatched class-key ‘class’ [-Wmismatched-tags]
1252 | template<typename, typename> friend class _State::_Setter;
| ^~~~~~~
/usr/include/c++/10/future:1252:57: note: replace the class-key with ‘struct’
There are a few others emitted by a clang++ build using the GCC standard
library headers:
In file included from main.cpp:5:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/algorithm:64:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/ranges_algo.h:35:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/ranges_algobase.h:38:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/ranges:46:
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/tuple:195:49:
warning: class template '_Tuple_impl' was previously declared as a struct
template; this is valid, but may result in linker errors under the Microsoft
C++ ABI [-Wmismatched-tags]
template<std::size_t, typename...> friend class _Tuple_impl;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/tuple:183:12:
note: previous use is here
struct _Tuple_impl;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/tuple:344:49:
warning: class template '_Tuple_impl' was previously declared as a struct
template; this is valid, but may result in linker errors under the Microsoft
C++ ABI [-Wmismatched-tags]
template<std::size_t, typename...> friend class _Tuple_impl;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/tuple:183:12:
note: previous use is here
struct _Tuple_impl;
^
In file included from main.cpp:5:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/algorithm:74:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/pstl/glue_algorithm_defs.h:13:
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:401:5:
warning: '_Bind' defined as a class template here but previously declared as a
struct template; this is valid, but may result in linker errors under the
Microsoft C++ ABI [-Wmismatched-tags]
class _Bind<_Functor(_Bound_args...)>
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:398:5:
note: did you mean class here?
struct _Bind;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:552:5:
warning: '_Bind_result' defined as a class template here but previously
declared as a struct template; this is valid, but may result in linker errors
under the Microsoft C++ ABI [-Wmismatched-tags]
class _Bind_result<_Result, _Functor(_Bound_args...)>
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:549:5:
note: did you mean class here?
struct _Bind_result;
^
In file included from main.cpp:5:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/algorithm:60:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/utility:70:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_pair.h:59:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/move.h:57:
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/type_traits:2535:5:
warning: 'result_of' defined as a struct template here but previously declared
as a class template; this is valid, but may result in linker errors under the
Microsoft C++ ABI [-Wmismatched-tags]
struct result_of<_Functor(_ArgTypes...)>
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/type_traits:2344:5:
note: did you mean struct here?
class result_of;
^