public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55663] New: [C++11] Alias template combined with constexpr function is considered non-const
@ 2012-12-12 13:37 daniel.kruegler at googlemail dot com
  2012-12-14 21:36 ` [Bug c++/55663] " mlopez at cse dot tamu.edu
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-12 13:37 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-01-21 13:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12 13:37 [Bug c++/55663] New: [C++11] Alias template combined with constexpr function is considered non-const daniel.kruegler at googlemail dot com
2012-12-14 21:36 ` [Bug c++/55663] " mlopez at cse dot tamu.edu
2012-12-14 22:08 ` redi at gcc dot gnu.org
2012-12-21  9:48 ` paolo.carlini at oracle dot com
2012-12-22 22:01 ` dodji at gcc dot gnu.org
2012-12-23 17:18 ` dodji at gcc dot gnu.org
2013-01-15  9:13 ` dodji at gcc dot gnu.org
2013-01-15 11:28 ` dodji at gcc dot gnu.org
2013-01-16 20:23 ` jason at gcc dot gnu.org
2013-01-21 13:33 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).