[Bug c++/67704] New: [concepts] requirements not being applied to aliases

ryan.burn at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 24 06:05:00 GMT 2015


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

            Bug ID: 67704
           Summary: [concepts] requirements not being applied to aliases
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.burn at gmail dot com
  Target Milestone: ---

I think the below code should compile: the first version of "f" should trigger
SFINAE but the second version should match so that the program prints 2.

But it compiles with this error with gcc 6:

t3.cpp: In substitution of ‘template<class X>  requires
predicate(requires{typename X::type;}) using Q = typename X::type [with X =
int]’:
t3.cpp:12:21:   required from ‘struct A<int>’
t3.cpp:19:30:   required by substitution of ‘template<class X>  requires
predicate(requires{typename X::Q;}) using R = typename A::type [with X = int]’
t3.cpp:35:20:   required from here
t3.cpp:8:27: error: ‘int’ is not a class, struct, or union type
 using Q = typename X::type;

//////////////////////////////////////////////
#include <type_traits>                                                          
#include <iostream>                                                             

template<class X>                                                               
  requires requires {                                                           
    typename X::type;                                                           
  }                                                                             
using Q = typename X::type;                                                     

template <class X>                                                              
struct A {                                                                      
  using type = Q<X>*;                                                           
};                                                                              

template<class X>                                                               
  requires requires {                                                           
    typename Q<X>;                                                              
  }                                                                             
using R = typename A<X>::type;                                                  

template <class X>                                                              
  requires requires {                                                           
    typename R<X>;                                                              
  }                                                                             
int f(X x) {                                                                    
  return 1;                                                                     
}                                                                               

template<class X>                                                               
int f(X x) {                                                                    
  return 2;                                                                     
}                                                                               

int main() {                                                                    
  std::cout << f(22) << '\n';                                                   
  return 0;                                                                     
}
//////////////////////////////////////////////


More information about the Gcc-bugs mailing list