https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124312
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |redi at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In file included from
/home/jakub/src/gcc/obj14i/usr/local/include/c++/16.0.1/vector:68,
from
/home/jakub/src/gcc/obj14i/usr/local/include/c++/16.0.1/meta:49,
from pr124312.C:1:
pr124312.C:8:77: in ‘constexpr’ expansion of
‘((std::__cxx1998::vector<std::meta::info, std::allocator<std::meta::info>
>*)(& std::meta::annotations_of(^^E)))->std::__cxx1998::vector<std::meta::info,
std::allocator<std::meta::info> >::size()’
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
|
~~~~~~~~~~~~~~~~~~~~~~~~~~^~
pr124312.C:8:9: required by the constraints of ‘template<class T> concept
is_annotated_enum’
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
| ^~~~~~~~~~~~~~~~~
/home/jakub/src/gcc/obj14i/usr/local/include/c++/16.0.1/bits/stl_vector.h:1109:33:
error: accessing value of ‘std::__debug::vector<std::meta::info>’ object
through a ‘const std::__cxx1998::vector<std::meta::info,
std::allocator<std::meta::info> >’ glvalue in a constant expression
1109 | ptrdiff_t __dif = this->_M_impl._M_finish -
this->_M_impl._M_start;
| ~~~~~~^~~~~~~
pr124312.C:8:66: note: ‘std::__debug::vector<std::meta::info>’ object created
here
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
| ~~~~~~~~~~~~~~~^~~~~
pr124312.C:10:16: error: non-constant condition for static assertion
10 | static_assert (is_annotated_enum <E>);
| ^~~~~~~~~~~~~~~~~~~~~
pr124312.C:8:77: in ‘constexpr’ expansion of
‘((std::__cxx1998::vector<std::meta::info, std::allocator<std::meta::info>
>*)(& std::meta::annotations_of(^^E)))->std::__cxx1998::vector<std::meta::info,
std::allocator<std::meta::info> >::size()’
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
|
~~~~~~~~~~~~~~~~~~~~~~~~~~^~
pr124312.C:8:9: required by the constraints of ‘template<class T> concept
is_annotated_enum’
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
| ^~~~~~~~~~~~~~~~~
/home/jakub/src/gcc/obj14i/usr/local/include/c++/16.0.1/bits/stl_vector.h:1109:33:
error: accessing value of ‘std::__debug::vector<std::meta::info>’ object
through a ‘const std::__cxx1998::vector<std::meta::info,
std::allocator<std::meta::info> >’ glvalue in a constant expression
1109 | ptrdiff_t __dif = this->_M_impl._M_finish -
this->_M_impl._M_start;
| ~~~~~~^~~~~~~
pr124312.C:8:66: note: ‘std::__debug::vector<std::meta::info>’ object created
here
8 | concept is_annotated_enum = std::is_enum_v <T> && annotations_of
(^^T).size () > 0;
| ~~~~~~~~~~~~~~~^~~~~
I've verified annotations_of returns object of the
std::__debug::vector<std::meta::info> type (get_vector_info () looks that up).
That is:
template<typename _Tp,
typename _Allocator = std::allocator<_Tp> >
class vector
: public __gnu_debug::_Safe_container<
vector<_Tp, _Allocator>, _Allocator, __gnu_debug::_Safe_sequence>,
public __cxx1998::vector<_Tp, _Allocator>,
public __gnu_debug::_Safe_vector<
vector<_Tp, _Allocator>,
__cxx1998::vector<_Tp, _Allocator> >
and so it inherits from std::__cxx1998::vector<std::meta::info>, and doesn't
override its size() method.
The size method is then called from the right template:
std::__cxx1998::vector<std::meta::info, std::allocator<std::meta::info> >::size
((struct vector *) &TARGET_EXPR <D.74901, <<< Unknown tree: aggr_init_expr
4
annotations_of
D.74901
<<< Unknown tree: reflect_expr
E >>> >>>>);
where the first argument (this pointer) is NOP_EXPR to
std::__cxx1998::vector<std::meta::info, std::allocator<std::meta::info> > *
from ADDR_EXPR on the TARGET_EXPR which has the
std::__debug::vector<std::meta::info> type.