public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
[not found] <bug-37804-4@http.gcc.gnu.org/bugzilla/>
@ 2014-06-01 19:02 ` ilya.konstantinov at gmail dot com
2014-06-02 8:40 ` ilya.konstantinov at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: ilya.konstantinov at gmail dot com @ 2014-06-01 19:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
Ilya Konstantinov <ilya.konstantinov at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ilya.konstantinov at gmail dot com
--- Comment #6 from Ilya Konstantinov <ilya.konstantinov at gmail dot com> ---
This bug causes an error using llvm's libc++, e.g.:
#include <string>
void foo() {
string::iterator it; // friend-declares vector<_Tp,_Alloc>
}
#include <vector>
using std::vector; // <-- error: 'vector' is already declared in this scope
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
[not found] <bug-37804-4@http.gcc.gnu.org/bugzilla/>
2014-06-01 19:02 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation ilya.konstantinov at gmail dot com
@ 2014-06-02 8:40 ` ilya.konstantinov at gmail dot com
2014-06-02 9:32 ` redi at gcc dot gnu.org
2021-08-03 5:05 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 9+ messages in thread
From: ilya.konstantinov at gmail dot com @ 2014-06-02 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
--- Comment #7 from Ilya Konstantinov <ilya.konstantinov at gmail dot com> ---
Whoever has permission to change, please add 'rejects-valid' as per my example
in the previous comment.
P.S. this issue reproduces in g++ 4.8
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
[not found] <bug-37804-4@http.gcc.gnu.org/bugzilla/>
2014-06-01 19:02 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation ilya.konstantinov at gmail dot com
2014-06-02 8:40 ` ilya.konstantinov at gmail dot com
@ 2014-06-02 9:32 ` redi at gcc dot gnu.org
2021-08-03 5:05 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-02 9:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Here's the reduced form of the rejects-valid case from comment 6
namespace std
{
template <typename T>
struct basic_string
{
template<typename U>
friend struct vector;
};
}
std::basic_string<char> it; // injects std::vector<T> into global scope
namespace std
{
template<typename U>
struct vector { };
}
using std::vector;
f.cc:19:12: error: ‘vector’ is already declared in this scope
using std::vector;
^
That seems slightly different, as it only misbehaves when std::vector is a
template, i.e. this version compiles OK:
namespace std
{
template <typename T>
struct basic_string
{
friend struct foo;
};
}
std::basic_string<char> it; // does not inject std::foo
namespace std
{
struct foo { };
}
using std::foo;
Curiously, although the error for the first example says vector has already
been declared at global scope, it apparently refers to std::vector and yet is
considered incomplete:
namespace std
{
template <typename T>
struct basic_string
{
template<typename U>
friend struct bar;
};
}
std::basic_string<char> it; // injects std::bar<T> into global scope
namespace std
{
template<typename U>
struct bar { };
}
bar<int> b;
fr.cc:19:10: error: aggregate ‘std::bar<int> b’ has incomplete type and cannot
be defined
bar<int> b;
^
>From gcc-bugs-return-452976-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 02 09:48:23 2014
Return-Path: <gcc-bugs-return-452976-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3851 invoked by alias); 2 Jun 2014 09:48:23 -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 3810 invoked by uid 48); 2 Jun 2014 09:48:19 -0000
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/61387] New: [4.10 Regression] ~900 test failures on on x86_64-apple-darwin13 for g++ with -m64 after r211088
Date: Mon, 02 Jun 2014 09:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dominiq at lps dot ens.fr
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 cc cf_gcchost cf_gcctarget cf_gccbuild
Message-ID: <bug-61387-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-06/txt/msg00058.txt.bz2
Content-length: 2184
https://gcc.gnu.org/bugzilla/show_bug.cgi?ida387
Bug ID: 61387
Summary: [4.10 Regression] ~900 test failures on on
x86_64-apple-darwin13 for g++ with -m64 after r211088
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: dominiq at lps dot ens.fr
CC: iains at gcc dot gnu.org, ktietz70 at googlemail dot com
Host: x86_64-apple-darwin13
Target: x86_64-apple-darwin13
Build: x86_64-apple-darwin13
After r211088 I see ~900 test failures on on x86_64-apple-darwin13 for g++ with
-m64.
The tests fail with two kinds of ICEs:
/opt/gcc/_clean/gcc/testsuite/g++.dg/torture/pr58585.C: In member function
'virtual void B::_ZTv0_n24_N1B3fooEv()':
/opt/gcc/_clean/gcc/testsuite/g++.dg/torture/pr58585.C:20:17: error:
unrecognizable insn:
C::C() { bar(); }
^
(call_insn/j 4 3 5 (call (mem/u/c:DI (const:DI (unspec:DI [
(symbol_ref/i:DI ("_ZN1B3fooEv") [flags 0x1]
<function_decl 0x142785f00 foo>)
] UNSPEC_GOTPCREL)) [0 S8 A8])
(const_int 0 [0]))
/opt/gcc/_clean/gcc/testsuite/g++.dg/torture/pr58585.C:12 -1
(nil)
(nil))
/opt/gcc/_clean/gcc/testsuite/g++.dg/torture/pr58585.C:20:17: internal compiler
error: in insn_default_length, at config/i386/i386.md:1786
or
/opt/gcc/_clean/gcc/testsuite/g++.dg/debug/pr54499.C: In member function
'virtual void S3::_ZThn8_N2S3D1Ev()':
/opt/gcc/_clean/gcc/testsuite/g++.dg/debug/pr54499.C:22:1: error:
unrecognizable insn:
}
^
(call_insn/j 3 2 4 (call (mem/u/c:DI (const:DI (unspec:DI [
(symbol_ref/i:DI ("_ZN2S3D1Ev") [flags 0x1]
<function_decl 0x14278e500 __comp_dtor >)
] UNSPEC_GOTPCREL)) [0 S8 A8])
(const_int 0 [0]))
/opt/gcc/_clean/gcc/testsuite/g++.dg/debug/pr54499.C:14 -1
(nil)
(nil))
/opt/gcc/_clean/gcc/testsuite/g++.dg/debug/pr54499.C:22:1: internal compiler
error: in insn_default_length, at config/i386/i386.md:1786
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
[not found] <bug-37804-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2014-06-02 9:32 ` redi at gcc dot gnu.org
@ 2021-08-03 5:05 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 5:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |11.0
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 11, most likely by r11-3361, the testcase and the case here look
very similar.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
` (3 preceding siblings ...)
2008-12-30 11:53 ` rguenth at gcc dot gnu dot org
@ 2009-01-15 23:07 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-15 23:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2009-01-15 23:07 -------
7.3.1.2: If a friend declaration in a non-local class first declares a class or
function the friend class or function is a member of the innermost enclosing
namespace. The name of the friend is not found by unqualified lookup (3.4.1) or
by qualified lookup (3.4.3) until a matching declaration is provided in that
namespace scope (either before or after the class definition granting
friendship).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
` (2 preceding siblings ...)
2008-10-11 18:47 ` rguenth at gcc dot gnu dot org
@ 2008-12-30 11:53 ` rguenth at gcc dot gnu dot org
2009-01-15 23:07 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-30 11:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2008-12-30 11:52 -------
14.6.5 [temp.inject]
suggests that this is valid. EDG doesn't agree with that in strict-ansi mode.
t2.C(9): error: identifier "B" is undefined
B some_function(); // B should not be declared here
^
compilation aborted for t2.C (code 2)
(testcase from comment #1)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
2008-10-11 13:08 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation rguenth at gcc dot gnu dot org
2008-10-11 17:06 ` pinskia at gmail dot com
@ 2008-10-11 18:47 ` rguenth at gcc dot gnu dot org
2008-12-30 11:53 ` rguenth at gcc dot gnu dot org
2009-01-15 23:07 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-11 18:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-10-11 18:46 -------
Related to PR37775, PR34827 and PR31336. (search for accepts-invalid and
'friend')
Seems like friend declarations are not an uncommon source for problems...
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com
BugsThisDependsOn| |31336, 34827, 37775
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
2008-10-11 13:08 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation rguenth at gcc dot gnu dot org
@ 2008-10-11 17:06 ` pinskia at gmail dot com
2008-10-11 18:47 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: pinskia at gmail dot com @ 2008-10-11 17:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gmail dot com 2008-10-11 17:05 -------
Subject: Re: New: Nested type leaks to global scope
Sent from my iPhone
On Oct 11, 2008, at 5:28 AM, "therealfroggey at gmail dot com"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> GCC versions used:
> gcc version 4.1.2
> gcc version 4.4.0 20081011 (experimental) (GCC) svn revision 141055
> Command line used: g++ -Wall -Wextra bug.cc
>
> The following code should fail to compile as Internal_B is a private
> class
> within class A.
> Both tested version of gcc successfully compile it with no warnings.
>
> ------------
>
> template <typename T>
> class A
> {
> private:
> class Internal_A
> {
> friend class Internal_B;
The above friend class refers to the class in containing namespace and
not to the class inside the class.
>
> };
> class Internal_B { };
> Internal_A a;
> };
>
> A<int> a;
>
> Internal_B some_function();
The above should not compile but it is not because the inner class is
leaking though. It is because the friend statement is causing an
injection when it should not.
>
>
>
> --
> Summary: Nested type leaks to global scope
> Product: gcc
> Version: 4.4.0
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c++
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: therealfroggey at gmail dot com
> GCC build triplet: x86_64-linux-gnu
> GCC host triplet: x86_64-linux-gnu
> GCC target triplet: x86_64-linux-gnu
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/37804] friend declaration leaks into global scope at template instantiation
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
@ 2008-10-11 13:08 ` rguenth at gcc dot gnu dot org
2008-10-11 17:06 ` pinskia at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-11 13:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-10-11 13:07 -------
Confirmed. The friend declaration seems to inject Internal_B into the global
namespace at the point of instantiating the template A.
Reduced testcase:
template <typename T>
struct A
{
friend class B;
};
A<int> a; // here we inject a declaration of B into the global namespace
B some_function(); // B should not be declared here
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |accepts-invalid
Last reconfirmed|0000-00-00 00:00:00 |2008-10-11 13:07:05
date| |
Summary|Nested type leaks to global |friend declaration leaks
|scope |into global scope at
| |template instantiation
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37804
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-03 5:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-37804-4@http.gcc.gnu.org/bugzilla/>
2014-06-01 19:02 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation ilya.konstantinov at gmail dot com
2014-06-02 8:40 ` ilya.konstantinov at gmail dot com
2014-06-02 9:32 ` redi at gcc dot gnu.org
2021-08-03 5:05 ` pinskia at gcc dot gnu.org
2008-10-11 12:30 [Bug c++/37804] New: Nested type leaks to global scope therealfroggey at gmail dot com
2008-10-11 13:08 ` [Bug c++/37804] friend declaration leaks into global scope at template instantiation rguenth at gcc dot gnu dot org
2008-10-11 17:06 ` pinskia at gmail dot com
2008-10-11 18:47 ` rguenth at gcc dot gnu dot org
2008-12-30 11:53 ` rguenth at gcc dot gnu dot org
2009-01-15 23:07 ` jason at gcc dot gnu dot 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).