public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60463] New: Lambda function can call a non-const member function with const this
@ 2014-03-07 23:32 topi.musto at gmail dot com
  2014-04-12 19:37 ` [Bug c++/60463] " momchil.velikov at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: topi.musto at gmail dot com @ 2014-03-07 23:32 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2015-02-05 14:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 23:32 [Bug c++/60463] New: Lambda function can call a non-const member function with const this topi.musto at gmail dot com
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

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