http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55663



             Bug #: 55663

           Summary: [C++11] Alias template combined with constexpr

                    function is considered non-const

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: daniel.krueg...@googlemail.com





Using gcc 4.8.0 20121209 (experimental) and compile with flags



-Wall -std=c++11 -pedantic



rejects the following program:



//-------------------------------

template<bool, class>

struct enable_if {};



template<class T>

struct enable_if<true, T> { using type = T; };



template<bool C, class T>

using req = typename enable_if<C, T>::type;



template<class T>

constexpr bool always() { return true; }



template<class T>

typename enable_if<always<T>(), void>::type

foo1(T){}



template<class T>

req<always<T>(), void>

foo2(T){}



int main() {

  foo1(0); // OK

  foo2(0); // Error #23

}

//-------------------------------



the diagnostics being:



"main.cpp||In function 'int main()':|

main.cpp|23|error: no matching function for call to 'foo2(int)'|

main.cpp|23|note: candidate is:|

main.cpp|19|note: template<class T> req<always<T>(), void> foo2(T)|

main.cpp|19|note:   template argument deduction/substitution failed:|

main.cpp|19|  required by substitution of 'template<class T> req<always<T>(),

void> foo2(T) [with T = int]'|

main.cpp|23|required from here|

main.cpp|19|error: integral expression 'always<int>()' is not constant|

main.cpp|19|error:   trying to instantiate 'template<bool C, class T> using req

= typename enable_if::type'|

"



I found some similarity to bug 54648 but I'm not 100% sure whether this is a

dub

Reply via email to