This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64969] generic functions do not work with placeholder return types


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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #3 from Harald van Dijk <harald at gigawatt dot nl> ---
This happens because auto is encoded as a template parameter that is one level
deeper than the currently deepest real template parameter. In other words,
  auto f()
is encoded as
  <<template-param-1-1>> f(),
and
  template <typename T> auto f()
is encoded as
  template <typename T> <<template-param-2-1>> f().

Given
  auto f1(auto x),
when the first auto is parsed, it becomes
  <<template-param-1-1>> f1(auto x).
When the second auto is parsed, and the function implicitly becomes a template,
it looks like
  template <typename <<auto>> > <<template-param-1-1>>
f1(<<template-param-1-1>> x)
where the first <<template-param-1-1>> should be <<template-param-2-1>>.

Instead of fixing up existing references to auto when a function is implicitly
made a template, how about encoding auto as a template argument with a level of
zero, and adding a tf_auto flag for tsubst to specify that auto is to be
replaced? If that flag is specified, fix up the zero by changing it to
(processing_template_decl+1), if that flag is not specified, leave auto alone.
All that seems to be needed aside from that, in a quick test, is making
reduce_template_parm_level aware of them, making it leave a level of zero at
zero. The cases in this bug pass, and manually running tests on
gcc/testsuite/g++.dg/cpp1y/auto* doesn't show problems either. I'll do some
more extensive testing, and also run the full test suite.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]