[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-23 Thread rafael at espindo dot la
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #13 from Rafael Avila de Espindola  ---
Thank you so much. I can confirm that scylla now builds with gcc master with
just a few fixes on the scylla side (we build with -Werror).

There is a couple of test failures. I will try to reduce those and open new
bugs as appropriate.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-23 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #11 from CVS Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:f9f166251f181ddcee64092d89aecbc1166ca706

commit r10-7932-gf9f166251f181ddcee64092d89aecbc1166ca706
Author: Patrick Palka 
Date:   Thu Apr 23 17:29:55 2020 -0400

c++: Lambda in friend of constrained class [PR94645]

In the testcase below, when grokfndecl processes the operator() decl for
the
lambda inside the friend function foo, processing_template_decl is rightly
1,
but template_class_depth on the lambda's closure type incorrectly returns 0
instead of 1.

Since processing_template_decl > template_class_depth, this makes
grokfndecl
think that the operator() has its own set of template arguments, and so we
attach the innermost set of constraints -- those belonging to struct l --
to the
operator() decl.  We then get confused when checking
constraints_satisfied_p on
the operator() because it doesn't have template information and yet has
constraints associated with it.

This patch fixes template_class_depth to return the correct template
nesting
level in cases like these, in that when it hits a friend function it walks
into
the DECL_FRIEND_CONTEXT of the friend rather than into the CP_DECL_CONTEXT.

gcc/cp/ChangeLog:

PR c++/94645
* pt.c (template_class_depth): Walk into the DECL_FRIEND_CONTEXT of
a
friend declaration rather than into its CP_DECL_CONTEXT.

gcc/testsuite/ChangeLog:

PR c++/94645
* g++.dg/cpp2a/concepts-lambda6.C: New test.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-23 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Patrick Palka  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #12 from Patrick Palka  ---
Fixed.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-23 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #10 from Patrick Palka  ---
Oops, it turns out the ICEs I was seeing in the cmcstl2 testsuite with the
change in #c9 were actually due to PR94719, which has since been fixed.  The
cmcstl2 testsuite now compiles fine with or without the change in #c9 FWIW.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-22 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Jason Merrill  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
 Status|NEW |ASSIGNED

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-21 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #9 from Patrick Palka  ---
Thanks for the reduced testcases.


The problem in #c8 seems to start in grokfndecl() when processing the
operator() of the lambda.  During grokfndecl on the operator(),
processing_template_decl is 1 but template_class_depth is 0 (seems it should be
1 here?).  So the condition for 'memtmpl' in

  tree ctx = friendp ? current_class_type : ctype;
  bool memtmpl = (processing_template_decl > template_class_depth (ctx));

is true for this non-templated lambda, but IIUC 'memtmpl' should be true only
if the declaration in question has its own set of template parameters, which is
not the case here.

Since memtmpl is true, we then attach the innermost constraints (belonging to
struct l) to this non-templated operator() via:

  if (memtmpl)
tmpl_reqs = TEMPLATE_PARMS_CONSTRAINTS (current_template_parms);
  tree ci = build_constraints (tmpl_reqs, decl_reqs);
  ...
  set_constraints (decl, ci);

and thing goes downhill from there.


I tried fixing template_class_depth to return 1 in this case via

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -390,7 +390,12 @@ template_class_depth (tree type)
++depth;

   if (DECL_P (type))
-   type = CP_DECL_CONTEXT (type);
+   {
+ if (tree fctx = DECL_FRIEND_CONTEXT (type))
+   type = fctx;
+ else
+   type = CP_DECL_CONTEXT (type);
+   }
   else if (LAMBDA_TYPE_P (type) && LAMBDA_TYPE_EXTRA_SCOPE (type))
type = LAMBDA_TYPE_EXTRA_SCOPE (type);
   else

but this change causes a bunch of ICEs in the cmcstl2 testsuite.

It seems that the condition for 'memtmpl' needs adjusting, but I'm not sure
how.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-21 Thread rafael at espindo dot la
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #8 from Rafael Avila de Espindola  ---
The internal compiler error reduces to

struct unordered_map {
int cend() const noexcept;
};
template  concept HasMapInterface = requires(a t) { t.cend(); };
template 
requires HasMapInterface struct l {
friend void foo(l opt) {
  ([]() {})();
  }
};
struct p {
  static unordered_map map();
};
void g(l *y) { foo(*y); }

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-21 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

--- Comment #7 from Patrick Palka  ---
As in PR94597, I think the testcases here in #c0 and #c2 might be invalid as-is
-- the requirement "t.cend;" should probably be "t.cend();", and we reject the
former since r10-7554.

With that minor change we successfully compile the reduced testcase, but we
still get the same ICE with the original testcase.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-21 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Patrick Palka  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   Assignee|ppalka at gcc dot gnu.org  |unassigned at gcc dot 
gnu.org

--- Comment #6 from Patrick Palka  ---
Oops, accidentally assigned myself this bug; unassigning.

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-21 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Patrick Palka  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org
 Status|NEW |ASSIGNED
 CC||ppalka at gcc dot gnu.org

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Martin Liška  changed:

   What|Removed |Added

 Status|WAITING |NEW

[Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257

2020-04-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94645

Martin Liška  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org
  Known to work||9.3.0
  Known to fail||10.0
Summary|[10 Regression][concepts]   |[10 Regression][concepts]
   |incorrect concept   |incorrect concept
   |evaluation with decltype,   |evaluation with decltype,
   |plus internal error |plus internal error since
   ||r10-7554-gf1ad7bac76b66257

--- Comment #5 from Martin Liška  ---
Sorry, you are right. Reproduced now, the error started with
r10-7554-gf1ad7bac76b66257.