public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60245] New: Template static  function not accepted as constexpr parameter
@ 2014-02-17 16:46 florent.hivert at lri dot fr
  2014-02-17 17:10 ` [Bug c++/60245] " florent.hivert at lri dot fr
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: florent.hivert at lri dot fr @ 2014-02-17 16:46 UTC (permalink / raw)
  To: gcc-bugs

[-- 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


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

* [Bug c++/60245] Template static  function not accepted as constexpr parameter
  2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
@ 2014-02-17 17:10 ` 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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: florent.hivert at lri dot fr @ 2014-02-17 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Florent Hivert <florent.hivert at lri dot fr> ---
Sorry ! The version I submitted is not the most reduced. Here is a version not
using vectors:

constexpr int Apply(const int in, int (*f)(const int&)) { return f(in); }

using Foo = int;
static constexpr int id(const Foo& i) { return i; }
static constexpr int results1 = Apply(0, &id);


Note: Replacing the Foo by int in the definition of id makes the problem
vanish.


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

* [Bug c++/60245] function with using defined parameter not accepted as constexpr parameter
  2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
  2014-02-17 17:10 ` [Bug c++/60245] " florent.hivert at lri dot fr
@ 2014-05-28 10:02 ` florent.hivert at lri dot fr
  2014-11-18 11:46 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: florent.hivert at lri dot fr @ 2014-05-28 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

Florent Hivert <florent.hivert at lri dot fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|4.8.1                       |4.9.0

--- Comment #3 from Florent Hivert <florent.hivert at lri dot fr> ---
The problem remains with the newly released gcc 4.9.0. I upgraded the version
tag.


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

* [Bug c++/60245] function with using defined parameter not accepted as constexpr parameter
  2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
  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
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |55004

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is fixed in mainline, I'm adding the testcase and closing the bug.


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

* [Bug c++/60245] function with using defined parameter not accepted as constexpr parameter
  2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-11-18 11:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue Nov 18 11:57:16 2014
New Revision: 217709

URL: https://gcc.gnu.org/viewcvs?rev=217709&root=gcc&view=rev
Log:
2014-11-18  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/60245
    * g++.dg/cpp0x/constexpr-60245.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-60245.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/60245] function with using defined parameter not accepted as constexpr parameter
  2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
                   ` (3 preceding siblings ...)
  2014-11-18 11:57 ` paolo at gcc dot gnu.org
@ 2014-11-18 11:58 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.


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

end of thread, other threads:[~2014-11-18 11:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 16:46 [Bug c++/60245] New: Template static function not accepted as constexpr parameter florent.hivert at lri dot fr
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

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).