public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juchem at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/62277] New: [C++11] constexpr member methods are treated as const, regardless of const modifier
Date: Wed, 27 Aug 2014 06:24:00 -0000	[thread overview]
Message-ID: <bug-62277-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2014-08-27  6:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  6:24 juchem at gmail dot com [this message]
2014-08-27  9:27 ` [Bug c++/62277] " redi at gcc dot gnu.org

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