Bug 59483 - A nested lambda fails to find a protected name with qualified name
Summary: A nested lambda fails to find a protected name with qualified name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2013-12-12 13:30 UTC by Ville Voutilainen
Modified: 2022-03-11 00:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ville Voutilainen 2013-12-12 13:30:01 UTC
Test:

struct X { 
protected: 
  int i; 
};  

struct Y: X { 
  void f() { 
    [&]{ X::i = 3; }(); } // #1
};

Output:

eelis.cpp: In lambda function:
eelis.cpp:3:7: error: ‘int X::i’ is protected
   int i; 
       ^
eelis.cpp:8:13: error: within this context
     [&]{ X::i = 3; }(); } 
             ^
Removing X:: from #1 makes it work. Clang 3.4 accepts the code either
with X:: or without it.
Comment 1 Jason Merrill 2014-06-02 20:48:27 UTC
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
Comment 2 Ville Voutilainen 2014-06-03 18:16:39 UTC
It seems that 58972 is a duplicate, and is fixed by the same patch.
Comment 3 Ville Voutilainen 2014-06-04 17:42:34 UTC
So, correction, the original testcase in 58972 is fixed by this patch, but the other testcase in it ICEs the compiler. That testcase is not really related to the issue the patch fixes, or the patch itself, it seems separate, and we could certainly create a separate bug for it, but I guess it can be fixed under the auspices of 58972.
Comment 4 Jason Merrill 2014-06-09 19:25:53 UTC
Fixed on trunk.