public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62277] New: [C++11] constexpr member methods are treated as const, regardless of const modifier
@ 2014-08-27  6:24 juchem at gmail dot com
  2014-08-27  9:27 ` [Bug c++/62277] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: juchem at gmail dot com @ 2014-08-27  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 62277
           Summary: [C++11] constexpr member methods are treated as const,
                    regardless of const modifier
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juchem at gmail dot com

The following code fails to compile. Tested in Debian sid (g++ 4.8.3-9 and
4.9.1-9) and in http://ideone.com (gcc 4.8.1).

Defining CONSTEXPR to an empty macro compiles and runs successfully.

----------------------------------------------
#include <iostream>

#define CONSTEXPR constexpr

struct foo {
    CONSTEXPR char const *bar() const { return "const"; }
    CONSTEXPR char const *bar() { return "non-const"; }
};

int main() {
    foo f;
    std::cout << f.bar() << std::endl;

    foo const b;
    std::cout << b.bar() << std::endl;

    return 0;
}
----------------------------------------------

output: 
prog.cpp:7:24: error: ‘constexpr const char* foo::bar() const’ cannot be
overloaded
  CONSTEXPR char const *bar() { return "non-const"; }
                        ^
prog.cpp:6:24: error: with ‘constexpr const char* foo::bar() const’
  CONSTEXPR char const *bar() const { return "const"; }

gcc versions in debian:
$ g++-4.8 --version
g++-4.8 (Debian 4.8.3-9) 4.8.3
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++-4.9 --version
g++-4.9 (Debian 4.9.1-9) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>From gcc-bugs-return-459326-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Aug 27 06:41:31 2014
Return-Path: <gcc-bugs-return-459326-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6498 invoked by alias); 27 Aug 2014 06:41:31 -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 6429 invoked by uid 48); 27 Aug 2014 06:41:26 -0000
From: "amker at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/62265] [4.8/4.9/5 regression] FAIL: gcc.dg/20111227-2.c scan-rtl-dump ree "Elimination opportunities = 3 realized = 3"
Date: Wed, 27 Aug 2014 06:41:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: amker at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed
Message-ID: <bug-62265-4-xGEGZezsAN@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62265-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62265-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-08/txt/msg01823.txt.bz2
Content-length: 548

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

amker at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-08-27
                 CC|                            |amker at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from amker at gcc dot gnu.org ---
Confirmed on many arm/aarch64 triplets.


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

* [Bug c++/62277] [C++11] constexpr member methods are treated as const, regardless of const modifier
  2014-08-27  6:24 [Bug c++/62277] New: [C++11] constexpr member methods are treated as const, regardless of const modifier juchem at gmail dot com
@ 2014-08-27  9:27 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2014-08-27  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is what C++11 requires, not a bug.

The C++14 relaxed constexpr rules aren't implemented yet, as documented at
https://gcc.gnu.org/projects/cxx1y.html


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

end of thread, other threads:[~2014-08-27  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-27  6:24 [Bug c++/62277] New: [C++11] constexpr member methods are treated as const, regardless of const modifier juchem at gmail dot com
2014-08-27  9:27 ` [Bug c++/62277] " redi 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).