public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61148] New: Cannot access protected members from a lambda capturing this
@ 2014-05-11 23:09 ville.voutilainen at gmail dot com
  2014-05-11 23:17 ` [Bug c++/61148] " ville.voutilainen at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-05-11 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61148
           Summary: Cannot access protected members from a lambda
                    capturing this
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

Test:

class DB {
        protected:
        void foo() {};
};
class DC : public DB {
        public:
        DC() {
                [this]() {
                        DB::foo(); // #1
                }();
        };
};

int main(void)
{
        DC x;
}

This is potentially a duplicate of
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58972

Clang accepts the code. gcc prints

lambda-protected.cpp: In lambda function:
lambda-protected.cpp:3:14: error: ‘void DB::foo()’ is protected
         void foo() {};
              ^
lambda-protected.cpp:9:33: error: within this context
                         DB::foo();
                                 ^

And changing #1 to this->DB::foo(); does not help.
>From gcc-bugs-return-451273-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun May 11 23:12:07 2014
Return-Path: <gcc-bugs-return-451273-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19479 invoked by alias); 11 May 2014 23:12:05 -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 19450 invoked by uid 48); 11 May 2014 23:11:59 -0000
From: "jengelh at inai dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61149] New: g++ rejects invocation of protected base class function from lambda
Date: Sun, 11 May 2014 23:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jengelh at inai dot de
X-Bugzilla-Status: UNCONFIRMED
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-61149-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg00965.txt.bz2
Content-length: 2092

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

            Bug ID: 61149
           Summary: g++ rejects invocation of protected base class
                    function from lambda
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de

gcc-4.9.0 SVN r209782 and gcc 4.8.2 reject this code:

    class B { protected: void foo(void) {}; };
    class S : public B {
        public: S(void) { [this](void) { B::foo(); }(); };
    };


$ g++ -c q.cpp -std=gnu++11
q.cpp: In lambda function:
q.cpp:4:7: error: ‘void B::foo()’ is protected
  void foo(void) {};
       ^
q.cpp:9:25: error: within this context
   [this](void) { B::foo(); }();

                         ^
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--enable-linux-futex --program-suffix=-4.8 --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
--host=x86_64-suse-linux
Thread model: posix
gcc version 4.8.2 20140404 [gcc-4_8-branch revision 209122] (SUSE Linux) 


clang is fine with it:

$ clang++ -c q.cpp -std=gnu++11
$ clang++ -v
clang version 3.3 (branches/release_33 183898)
Target: x86_64-suse-linux
Thread model: posix
>From gcc-bugs-return-451274-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun May 11 23:16:46 2014
Return-Path: <gcc-bugs-return-451274-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21317 invoked by alias); 11 May 2014 23:16:45 -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 21289 invoked by uid 48); 11 May 2014 23:16:40 -0000
From: "jengelh at inai dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61148] Cannot access protected members from a lambda capturing this
Date: Sun, 11 May 2014 23:16: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.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jengelh at inai dot de
X-Bugzilla-Status: UNCONFIRMED
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-61148-4-c3T3HVx4bD@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61148-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61148-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-05/txt/msg00966.txt.bz2
Content-length: 450

http://gcc.gnu.org/bugzilla/show_bug.cgi?ida148

Jan Engelhardt <jengelh at inai dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jengelh at inai dot de

--- Comment #1 from Jan Engelhardt <jengelh at inai dot de> ---
Definitely a duplicate of http://gcc.gnu.org/bugzilla/show_bug.cgi?ida149 ;)


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

* [Bug c++/61148] Cannot access protected members from a lambda capturing this
  2014-05-11 23:09 [Bug c++/61148] New: Cannot access protected members from a lambda capturing this ville.voutilainen at gmail dot com
@ 2014-05-11 23:17 ` ville.voutilainen at gmail dot com
  2014-05-12  8:28 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-05-11 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Most likely caused by the same problem as
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59483


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

* [Bug c++/61148] Cannot access protected members from a lambda capturing this
  2014-05-11 23:09 [Bug c++/61148] New: Cannot access protected members from a lambda capturing this ville.voutilainen at gmail dot com
  2014-05-11 23:17 ` [Bug c++/61148] " ville.voutilainen at gmail dot com
@ 2014-05-12  8:28 ` paolo.carlini at oracle dot com
  2014-06-02 20:48 ` jason at gcc dot gnu.org
  2014-06-09 19:25 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-05-12  8:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 61149 has been marked as a duplicate of this bug. ***


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

* [Bug c++/61148] Cannot access protected members from a lambda capturing this
  2014-05-11 23:09 [Bug c++/61148] New: Cannot access protected members from a lambda capturing this ville.voutilainen at gmail dot com
  2014-05-11 23:17 ` [Bug c++/61148] " ville.voutilainen at gmail dot com
  2014-05-12  8:28 ` paolo.carlini at oracle dot com
@ 2014-06-02 20:48 ` jason at gcc dot gnu.org
  2014-06-09 19:25 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-02 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Mon Jun  2 20:47:55 2014
New Revision: 211147

URL: http://gcc.gnu.org/viewcvs?rev=211147&root=gcc&view=rev
Log:
    PR c++/59483
    PR c++/61148
    * search.c (accessible_p): Use current_nonlambda_class_type.
    * semantics.c (check_accessibility_of_qualified_id): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/search.c
    trunk/gcc/cp/semantics.c


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

* [Bug c++/61148] Cannot access protected members from a lambda capturing this
  2014-05-11 23:09 [Bug c++/61148] New: Cannot access protected members from a lambda capturing this ville.voutilainen at gmail dot com
                   ` (2 preceding siblings ...)
  2014-06-02 20:48 ` jason at gcc dot gnu.org
@ 2014-06-09 19:25 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-09 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.10.0

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


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

end of thread, other threads:[~2014-06-09 19:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-11 23:09 [Bug c++/61148] New: Cannot access protected members from a lambda capturing this ville.voutilainen at gmail dot com
2014-05-11 23:17 ` [Bug c++/61148] " ville.voutilainen at gmail dot com
2014-05-12  8:28 ` paolo.carlini at oracle dot com
2014-06-02 20:48 ` jason at gcc dot gnu.org
2014-06-09 19:25 ` 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).