public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly
@ 2015-01-09  5:36 ville.voutilainen at gmail dot com
  2015-01-09  6:47 ` [Bug c++/64547] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ville.voutilainen at gmail dot com @ 2015-01-09  5:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64547
           Summary: A non-const constexpr function is rejected incorrectly
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
                CC: jason at redhat dot com

struct X 
{
    int x; 
    constexpr int get() const {return x;} 
    constexpr void set(int foo) {x = foo;}
}; 

constexpr int bar() 
{
    X x{42}; 
    x.set(666); 
    return x.get();
} 

int main() 
{
    constexpr int foo = bar();
}

Clang accepts the code, gcc rejects with 

constexpr-member.cpp: In function ‘int main()’:
constexpr-member.cpp:17:28:   in constexpr expansion of ‘bar()’
constexpr-member.cpp:11:10:   in constexpr expansion of ‘x.X::set(666)’
constexpr-member.cpp:17:29: error: constexpr call flows off the end of the
function
     constexpr int foo = bar();
>From gcc-bugs-return-472549-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 09 05:37:37 2015
Return-Path: <gcc-bugs-return-472549-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1847 invoked by alias); 9 Jan 2015 05:37:37 -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 1828 invoked by uid 48); 9 Jan 2015 05:37:33 -0000
From: "ville.voutilainen at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/62277] [C++11] constexpr member methods are treated as const, regardless of const modifier
Date: Fri, 09 Jan 2015 05:37: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.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ville.voutilainen at gmail dot com
X-Bugzilla-Status: RESOLVED
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
Message-ID: <bug-62277-4-zvm61G3Jy0@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62277-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62277-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: 2015-01/txt/msg00543.txt.bz2
Content-length: 523

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ville.voutilainen at gmail dot com

--- Comment #2 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
For what it's worth, now that C++14 relaxed constexpr rules are implemented,
the test snippet compiles fine.


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

* [Bug c++/64547] A non-const constexpr function is rejected incorrectly
  2015-01-09  5:36 [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly ville.voutilainen at gmail dot com
@ 2015-01-09  6:47 ` jason at gcc dot gnu.org
  2015-01-12 14:15 ` jason at gcc dot gnu.org
  2015-01-12 15:22 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-09  6:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-01-09
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug c++/64547] A non-const constexpr function is rejected incorrectly
  2015-01-09  5:36 [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly ville.voutilainen at gmail dot com
  2015-01-09  6:47 ` [Bug c++/64547] " jason at gcc dot gnu.org
@ 2015-01-12 14:15 ` jason at gcc dot gnu.org
  2015-01-12 15:22 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-12 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Mon Jan 12 14:15:07 2015
New Revision: 219466

URL: https://gcc.gnu.org/viewcvs?rev=219466&root=gcc&view=rev
Log:
    PR c++/64547
    * constexpr.c (cxx_eval_call_expression): A call to a void
    function doesn't need to return a value.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-void2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c


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

* [Bug c++/64547] A non-const constexpr function is rejected incorrectly
  2015-01-09  5:36 [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly ville.voutilainen at gmail dot com
  2015-01-09  6:47 ` [Bug c++/64547] " jason at gcc dot gnu.org
  2015-01-12 14:15 ` jason at gcc dot gnu.org
@ 2015-01-12 15:22 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-12 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09  5:36 [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly ville.voutilainen at gmail dot com
2015-01-09  6:47 ` [Bug c++/64547] " jason at gcc dot gnu.org
2015-01-12 14:15 ` jason at gcc dot gnu.org
2015-01-12 15:22 ` jason at gcc dot gnu.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).