[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

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

Patrick Palka  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

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

[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

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

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

https://gcc.gnu.org/g:1d2290caad0dba52b285b47057b7c0e4e8d21feb

commit r10-8025-g1d2290caad0dba52b285b47057b7c0e4e8d21feb
Author: Patrick Palka 
Date:   Tue Apr 28 21:45:59 2020 -0400

c++: Satisfaction caching of inherited ctor [PR94819]

As observed in PR94719, an inherited constructor for an instantiation of
a constructor template confusingly has as its DECL_INHERITED_CTOR the
TEMPLATE_DECL of the constructor template rather than the particular
instantiation of the template.

This means two inherited constructors for two different instantiations
of the same constructor template have the same DECL_INHERITED_CTOR.  And
since in satisfy_declaration_constraints our decl satisfaction cache is
keyed off of the result of strip_inheriting_ctors, we may end up
conflating the satisfaction values of the two inherited constructors'
constraints.

This patch fixes this issue by using the original tree, not the result
of strip_inheriting_ctors, as the key to the decl satisfaction cache.

gcc/cp/ChangeLog:

PR c++/94819
* constraint.cc (satisfy_declaration_constraints): Use saved_t
instead of t as the key to decl_satisfied_cache.

gcc/testsuite/ChangeLog:

PR c++/94819
* g++.dg/cpp2a/concepts-inherit-ctor10.C: New test.
* g++.dg/cpp2a/concepts-inherit-ctor11.C: New test.

[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

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

Patrick Palka  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Last reconfirmed||2020-04-28
 CC||ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka  ---
Confirmed, thanks for the nice testcase.  I think the problem lies with how we
cache the constraints of an inherited constructor.  I am testing the following:

--- a/gcc/cp/constraint.cc  
+++ b/gcc/cp/constraint.cc  
@@ -2752,7 +2752,7 @@ satisfy_declaration_constraints (tree t, subst_info info) 
   info.in_decl = t;

   if (info.quiet ())   
-if (tree *result = hash_map_safe_get (decl_satisfied_cache, t))
+if (tree *result = hash_map_safe_get (decl_satisfied_cache, saved_t))  
   return *result;  

   /* Get the normalized constraints.  */   
@@ -2787,7 +2787,7 @@ satisfy_declaration_constraints (tree t, subst_info info) 
 }  

   if (info.quiet ())   
-hash_map_safe_put (decl_satisfied_cache, t, result);   
+hash_map_safe_put (decl_satisfied_cache, saved_t, result); 

   return result;   
 }

[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

2020-04-28 Thread daniel.kruegler at googlemail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94819

Daniel Krügler  changed:

   What|Removed |Added

 CC||daniel.kruegler@googlemail.
   ||com

--- Comment #2 from Daniel Krügler  ---
After removal of any library dependencies:

```c++
template
inline constexpr bool is_same_v = false;

template
inline constexpr bool is_same_v = true;

template 
struct alphabet_tuple_base
{
template 
requires is_same_v
constexpr alphabet_tuple_base(component_type) {} // commenting out
constexpr works?!

template 
requires (!is_same_v)
alphabet_tuple_base(indirect_component_type) {}
};

template 
struct structured_rna : alphabet_tuple_base {
using base_type = alphabet_tuple_base;
using base_type::base_type;
};

struct dna4 {};
struct rna4 {};

structured_rna t1{rna4{}}; // commenting out any of these works?!
structured_rna t2{dna4{}}; // commenting out any of these works?!
structured_rna t3{rna4{}}; // commenting out any of these works?!

int main() {}
```

[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

2020-04-28 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94819

Richard Biener  changed:

   What|Removed |Added

   Keywords||rejects-valid
  Known to work||9.3.0
   Target Milestone|--- |10.0

[Bug c++/94819] [10 Regression] Inherited and constrained constructors are "ambiguous" even if they aren't Pt. 2

2020-04-28 Thread gcc-bugs at marehr dot dialup.fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94819

--- Comment #1 from gcc-bugs at marehr dot dialup.fu-berlin.de ---
A slightly more reduced example:

```c++
#include 

template 
struct alphabet_tuple_base
{
template 
requires std::is_same_v
constexpr alphabet_tuple_base(component_type) {} // commenting out
constexpr works?!

template 
requires (!std::is_same_v)
alphabet_tuple_base(indirect_component_type) {};
};

template 
struct structured_rna : alphabet_tuple_base {
using base_type = alphabet_tuple_base;
using base_type::base_type;
};

struct dna4 {};
struct rna4 {};

structured_rna t1{rna4{}}; // commenting out any of these works?!
structured_rna t2{dna4{}}; // commenting out any of these works?!
structured_rna t3{rna4{}}; // commenting out any of these works?!
```

https://godbolt.org/z/VACou9