https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122875

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Boris Staletic from comment #7)
> (In reply to Marek Polacek from comment #6)
> > (In reply to Andrew Pinski from comment #5)
> > > (In reply to eczbek.void from comment #1)
> > > > This might also be related: https://godbolt.org/z/xxsrz1ozY
> > > > 
> > > > ```
> > > > template<int>
> > > > constexpr bool x = true;
> > > > 
> > > > template<int>
> > > > concept test = [:substitute(^^x, {}):];
> > > > ```
> > > > 
> > > > ```
> > > > <source>:7:37: internal compiler error: in cp_parser_splice_expression, 
> > > > at
> > > > cp/parser.cc:6166
> > > 
> > > This still happens on the trunk.
> > 
> > I don't see this; I get:
> > 
> > 122875.C:5:18: error: there are no arguments to ‘substitute’ that depend on
> > a template parameter, so a declaration of ‘substitute’ must be available
> > [-fpermissive]
> >     5 | concept test = [:substitute(^^x, {}):];
> 
> 
> The original test case is missing #include <meta>
> 
> Adding that, it fails to compile because of the following can_substitute:
> 
> ```
> #include <meta>
> template<typename>
> constexpr bool x = true;
> 
> struct A {};
> struct B : A {};
> static_assert(can_substitute(^^x, bases_of(^^B,
> std::meta::access_context::current())));
> ```
> 
> The actual error (not an ICE):
> 
> ```
> foo.cpp:10:29: error: non-constant condition for static assertion
>    10 | static_assert(can_substitute(^^x, bases_of(^^B,
> std::meta::access_context::current())));
>       |              
> ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> foo.cpp:10:29: error: uncaught exception of type ‘std::meta::exception’;
> ‘what()’: ‘invalid argument to can_substitute’
> ```
> 
> Using `{^^A}` instead of `basses_of(^^B, ...)` does compile.

Isn't that correct?  I mean, bases_of returns a vector of reflections of the
direct base class relationship, something you can't without reflection get hand
on and use as a template parameter.  Using {type_of(bases_of(^^B, uctx)[0])} or
{parent_of(bases_of(^^B, uctx)[0])} would be meaningful, or applying on all
members of the vector type_of or parent_of.

Reply via email to