C++ PATCH for c++/77337 (auto return and constexpr lambda)
Jakub Jelinek
jakub@redhat.com
Thu Nov 10 21:50:00 GMT 2016
On Thu, Nov 10, 2016 at 01:42:20PM -0800, Jason Merrill wrote:
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn33.C
> @@ -0,0 +1,27 @@
> +// PR c++/77337
> +// { dg-do compile { target c++14 } }
> +
> +template<typename Functor>
> +struct fix_type {
> + Functor functor;
> +
> + decltype(auto) operator()()
> + { return functor(*this); }
> +};
> +
> +template<typename Functor>
> +fix_type<Functor> fix(Functor functor)
> +{ return { functor }; }
> +
> +int main()
> +{
> + auto zero = fix
> + ([](auto& self) -> int // N.B. non-deduced, non-dependent return type
> + {
> + return 0;
> +
> + self(); // error: use of 'decltype(auto) fix_type<Functor>::operator()() [with Functor = main()::<lambda(auto:1&)>]' before deduction of 'auto'
Wouldn't it be clearer to turn that // error: line into
// { dg-bogus "use of \[^\n\r]* before deduction of 'auto'" }
so that it is clear that the error is undesirable even to casual reader?
> + });
> +
> + return zero();
> +}
Jakub
More information about the Gcc-patches
mailing list