Bug 29041 - failure to check for visible declaration of friend function to local class
Summary: failure to check for visible declaration of friend function to local class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 29843
  Show dependency treegraph
 
Reported: 2006-09-12 20:27 UTC by Jorn Wolfgang Rennecke
Modified: 2015-03-27 17:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.0, 4.9.0, 5.0
Known to fail: 2.95.3, 3.0.4, 3.2.3, 3.3.3, 3.4.0, 4.0.0, 4.1.0, 4.2.0
Last reconfirmed: 2006-09-19 05:00:18


Attachments
Simple example when compiler fails. (296 bytes, text/plain)
2007-01-10 23:39 UTC, Tomasz Kapela
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jorn Wolfgang Rennecke 2006-09-12 20:27:54 UTC
The following code should not compile:

int f(int);
void g()
{
  class C {
    friend int f(int);
  };
}

The C++ standard clause 11.4 ; 9 states that friend declarations in local
classes have different rules to friend declarations in regular classes. Friend
functions must be previously declared in the innermost enclosing non-class
scope.
Comment 1 Andrew Pinski 2006-09-19 05:00:18 UTC
Confirmed, not a regression.
Comment 2 Tomasz Kapela 2007-01-10 23:39:22 UTC
Created attachment 12882 [details]
Simple example when compiler fails.

I think that one should be able to compile this.
But there are bugs, depending on position of friend funcition declaration.
Comment 3 Paolo Carlini 2015-03-27 17:46:25 UTC
Fixed long time ago.