public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55663] New: [C++11] Alias template combined with constexpr function is considered non-const
Date: Wed, 12 Dec 2012 13:37:00 -0000	[thread overview]
Message-ID: <bug-55663-4@http.gcc.gnu.org/bugzilla/> (raw)


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


             reply	other threads:[~2012-12-12 13:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 13:37 daniel.kruegler at googlemail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55663-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).