public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "florent.hivert at lri dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60245] New: Template static  function not accepted as constexpr parameter
Date: Mon, 17 Feb 2014 16:46:00 -0000	[thread overview]
Message-ID: <bug-60245-4@http.gcc.gnu.org/bugzilla/> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 4674 bytes --]

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

            Bug ID: 60245
           Summary: Template static  function not accepted as constexpr
                    parameter
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: florent.hivert at lri dot fr

GCC is not able to compile the following code

#include <array>

using Ar = std::array<unsigned long, 10>;

template<typename T>
constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); }

static constexpr Ar id(const Ar& line) { return line; }
static constexpr Ar ar1 = {{1}};
static constexpr Ar results1 = Apply<Ar>(ar1, &id);

It complains that 

bug4.cpp:10:50:   in constexpr expansion of ‘Apply<std::array<long unsigned
int, 10ul> >((* & ar1), id)’
bug4.cpp:6:63: error: expression ‘id’ does not designate a constexpr function
 constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); }

This seems to be a problem with template substitution since manually
specializing the template makes the error vanish:

#include <array>

using Ar = std::array<unsigned long, 10>;

template<typename T>
constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); }

// manual specialization:
template<>
constexpr Ar Apply<Ar>(const Ar& in, Ar (*f)(const Ar&)) { return f(in); }

static constexpr Ar id(const Ar& line) { return line; }
static constexpr Ar ar1 = {{1}};
static constexpr Ar results1 = Apply<Ar>(ar1, &id);


System informations:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--program-suffix=-4.8 --enable-linux-futex --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.8.1 20130909 [gcc-4_8-branch revision 202388] (SUSE Linux)
>From gcc-bugs-return-443961-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Feb 17 16:47:45 2014
Return-Path: <gcc-bugs-return-443961-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 8815 invoked by alias); 17 Feb 2014 16:47:44 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 8786 invoked by uid 48); 17 Feb 2014 16:47:40 -0000
From: "florent.hivert at lri dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60245] Template static  function not accepted as constexpr parameter
Date: Mon, 17 Feb 2014 16:47:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: florent.hivert at lri dot fr
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-60245-4-FleUjSDQzk@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60245-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60245-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01718.txt.bz2
Content-length: 235

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`245

--- Comment #1 from Florent Hivert <florent.hivert at lri dot fr> ---
Created attachment 32155
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2155&actioníit
preprocessed code


             reply	other threads:[~2014-02-17 16:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 16:46 florent.hivert at lri dot fr [this message]
2014-02-17 17:10 ` [Bug c++/60245] " florent.hivert at lri dot fr
2014-05-28 10:02 ` [Bug c++/60245] function with using defined parameter " florent.hivert at lri dot fr
2014-11-18 11:46 ` paolo.carlini at oracle dot com
2014-11-18 11:57 ` paolo at gcc dot gnu.org
2014-11-18 11:58 ` 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-60245-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).