struct Fo...">

Link to the "auto" function as a template parameter

Here is the minimal (C ++ 14) code to reproduce the problem:

template <void (&a)()> struct Foo { static auto value() {} }; void bar() {} template struct Foo<Foo<bar>::value>; 

GNU C ++ "g ++ (Ubuntu 5.1.0-0ubuntu11 ~ 14.04.1) 5.1.0" The compiler emits:

 error: could not convert template argument 'Foo<a>::value<bar>' to 'void (&)()' template struct Foo<Foo<bar>::value>; ^ 

The first strange thing I notice is Foo<a>::value<bar> - a not substituted, but value somehow becomes a template?

The following pointless corrections reinforce my impression that this is a compiler error:

  • Declaring value() as returning void instead of its output
  • "Dereferencing" value : template struct Foo<*Foo<bar>::value>;
  • Parenthesizing value : template struct Foo<(Foo<bar>::value)>;
  • Creating a pointer: template <void (*a)()> struct Foo ...

Finally, Clang compiles my fragment in order.

So, is there an obscure standard sentence somewhere that forbids the first fragment, or did GCC just die on me?

+6
source share
1 answer

This behavior was recognized as a bug and was filed by GCC Bugzilla .

0
source

All Articles