public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr
@ 2014-09-17  2:56 roc at ocallahan dot org
  2014-09-17 13:55 ` [Bug c++/63283] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: roc at ocallahan dot org @ 2014-09-17  2:56 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: 4899 bytes --]

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

            Bug ID: 63283
           Summary: constexpr function called by templated function is not
                    treated as constexpr
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roc at ocallahan dot org

[roc@eternity tmp]$ cat test.cc
#include <stdio.h>
constexpr int array_length(int (&array)[3]) { return 3; }
int a[] = { 1, 2, 3 };
template <typename T> int f() {
  struct { int e[array_length(a)]; } t;
  return sizeof(t);
}
int main() { printf("%d\n", f<void>()); }

[roc@eternity tmp]$ g++ -std=c++11 -o ~/tmp/test ~/tmp/test.cc && ~/tmp/test
/home/roc/tmp/test.cc: In function ‘int f()’:
/home/roc/tmp/test.cc:5:33: error: array bound is not an integer constant
before ‘]’ token
   struct { int e[array_length(a)]; } t;
                                 ^
[roc@eternity tmp]$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.3/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-isl=/builddir/build/BUILD/gcc-4.8.3-20140624/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140624/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.3 20140624 (Red Hat 4.8.3-1) (GCC) 

My friend also sees this in g++ 4.9.1.

clang++ 3.4 compiles the code successfully. Removing "template <typename T>"
from f() (and changing main() to match) makes the problem go away.
>From gcc-bugs-return-461906-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Sep 17 06:23:55 2014
Return-Path: <gcc-bugs-return-461906-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2240 invoked by alias); 17 Sep 2014 06:23:54 -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 2181 invoked by uid 48); 17 Sep 2014 06:23:45 -0000
From: "amodra at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/63281] powerpc64le creates 64 bit constants from scratch instead of loading them
Date: Wed, 17 Sep 2014 06:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: amodra at gmail dot com
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: cc attachments.created
Message-ID: <bug-63281-4-yfBqirINR4@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63281-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63281-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-09/txt/msg01740.txt.bz2
Content-length: 623

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc281

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at gmail dot com

--- Comment #1 from Alan Modra <amodra at gmail dot com> ---
Created attachment 33503
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3503&actioníit
stop the inline expansion

This forces constants requiring more than one extra instruction for an inline
evaluation as compared to a memory load, into the TOC.


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

* [Bug c++/63283] constexpr function called by templated function is not treated as constexpr
  2014-09-17  2:56 [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr roc at ocallahan dot org
@ 2014-09-17 13:55 ` paolo.carlini at oracle dot com
  2015-01-15 20:46 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-09-17 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-09-17
             Blocks|                            |55004
     Ever confirmed|0                           |1


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

* [Bug c++/63283] constexpr function called by templated function is not treated as constexpr
  2014-09-17  2:56 [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr roc at ocallahan dot org
  2014-09-17 13:55 ` [Bug c++/63283] " paolo.carlini at oracle dot com
@ 2015-01-15 20:46 ` jason at gcc dot gnu.org
  2015-01-15 21:46 ` jason at gcc dot gnu.org
  2015-01-15 22:07 ` roc at ocallahan dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-15 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Jan 15 20:46:03 2015
New Revision: 219686

URL: https://gcc.gnu.org/viewcvs?rev=219686&root=gcc&view=rev
Log:
    PR c++/63283
    * constexpr.c (potential_constant_expression_1): Handle reference
    args in templates.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-template8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/testsuite/g++.dg/cpp0x/static_assert10.C


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

* [Bug c++/63283] constexpr function called by templated function is not treated as constexpr
  2014-09-17  2:56 [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr roc at ocallahan dot org
  2014-09-17 13:55 ` [Bug c++/63283] " paolo.carlini at oracle dot com
  2015-01-15 20:46 ` jason at gcc dot gnu.org
@ 2015-01-15 21:46 ` jason at gcc dot gnu.org
  2015-01-15 22:07 ` roc at ocallahan dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-15 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
   Target Milestone|---                         |5.0

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 5.


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

* [Bug c++/63283] constexpr function called by templated function is not treated as constexpr
  2014-09-17  2:56 [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr roc at ocallahan dot org
                   ` (2 preceding siblings ...)
  2015-01-15 21:46 ` jason at gcc dot gnu.org
@ 2015-01-15 22:07 ` roc at ocallahan dot org
  3 siblings, 0 replies; 5+ messages in thread
From: roc at ocallahan dot org @ 2015-01-15 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from roc at ocallahan dot org <roc at ocallahan dot org> ---
Thanks!!!


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

end of thread, other threads:[~2015-01-15 22:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-17  2:56 [Bug c++/63283] New: constexpr function called by templated function is not treated as constexpr roc at ocallahan dot org
2014-09-17 13:55 ` [Bug c++/63283] " paolo.carlini at oracle dot com
2015-01-15 20:46 ` jason at gcc dot gnu.org
2015-01-15 21:46 ` jason at gcc dot gnu.org
2015-01-15 22:07 ` roc at ocallahan dot org

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