public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "topi.musto at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60463] New: Lambda function can call a non-const member function with const this
Date: Fri, 07 Mar 2014 23:32:00 -0000	[thread overview]
Message-ID: <bug-60463-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 60463
           Summary: Lambda function can call a non-const member function
                    with const this
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: topi.musto at gmail dot com

The following C++11 translation unit shouldn't compile, because g is non-const
and f is const:

struct A
{
    void g()
    {
    }

    void f() const
    {
        [this]() { g(); }();
    }
};

Yet it compiles with g++ -std=c++11 -Wall -Wextra

Tested with
g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1, and
g++ (GCC) 4.9.0 20140307 (experimental)

Note that calling the function with this->g(); gives the expected error
message:
"error: passing ‘const A’ as ‘this’ argument of ‘void A::g()’ discards
qualifiers [-fpermissive]"
>From gcc-bugs-return-445763-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Mar 07 23:35:16 2014
Return-Path: <gcc-bugs-return-445763-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22348 invoked by alias); 7 Mar 2014 23:35:16 -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 22303 invoked by uid 48); 7 Mar 2014 23:35:13 -0000
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic
Date: Fri, 07 Mar 2014 23:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: kargl at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: janus at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-60450-4-5B25El2S9b@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60450-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60450-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-03/txt/msg00632.txt.bz2
Content-length: 534

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`450

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #6 from kargl at gcc dot gnu.org ---
(In reply to janus from comment #4)
> (In reply to janus from comment #3)
> > The following patch is sufficient to fix it on 4.8:
>
> ... and regtests cleanly.

Patch is OK with a testcase.


             reply	other threads:[~2014-03-07 23:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 23:32 topi.musto at gmail dot com [this message]
2014-04-12 19:37 ` [Bug c++/60463] " momchil.velikov at gmail dot com
2014-05-09 20:08 ` jason at gcc dot gnu.org
2014-05-20 20:26 ` jason at gcc dot gnu.org
2014-09-22 19:22 ` jason at gcc dot gnu.org
2015-02-05 14:28 ` gene at staubsaal dot de

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