public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode
@ 2004-06-16 12:15 redi at gcc dot gnu dot org
2004-06-17 2:04 ` [Bug libstdc++/16021] " redi at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 18+ messages in thread
From: redi at gcc dot gnu dot org @ 2004-06-16 12:15 UTC (permalink / raw)
To: gcc-bugs
All testsuite/23_containers/*/modifiers/swap.cc files FAIL to compile
when _GLIBCXX_DEBUG is defined.
The following code is adapted from the testsuite:
#define _GLIBCXX_DEBUG
#include <vector>
struct T { int i; };
int swap_calls;
namespace std
{
template<>
void
vector<T, allocator<T> >::swap(vector<T, allocator<T> >&)
{ ++swap_calls; }
}
// Should use vector specialization for swap.
int main()
{
std::vector<T> A;
std::vector<T> B;
swap_calls = 0;
std::swap(A, B);
return swap_calls;
}
Compiling this gives:
swap.cc:12: error: `allocator' was not declared in this scope
swap.cc:12: error: template argument 2 is invalid
swap.cc:12: error: variable or field `swap' declared void
swap.cc:12: error: `int __gnu_debug_def::vector<T, std::allocator<T> >::swap' is
not a static member of `class __gnu_debug_def::vector<T, std::allocator<T> >'
swap.cc:12: error: expected primary-expression before ')' token
swap.cc:13: error: expected `;' before '{' token
The same error happens for all containers on 3.4 and mainline.
The diagnostic is confusing, it first says allocator is not found, then
identifies it as std::allocator in another diagnostic that seems to think
the member function is static.
A solution is to qualify allocator as std::allocator, but this shouldn't
be necessary because _GLIBCXX_DEBUG shouldn't change the meaning of any
conforming program.
I *think* what might be happening is that in debug mode the "std"
namespace is really "__gnu_debug" and the (non-debug) standard library
is really in "_GLIBCXX_STD". This means that the unqualified name
"allocator" looks up in __gnu_debug and the global namespace, and so
doesn't find "_GLIBCXX_STD::allocator". But I don't think I've got that
quite right.
--
Summary: Tests for container swap specialisations FAIL in debug
mode
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: redi at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
@ 2004-06-17 2:04 ` redi at gcc dot gnu dot org
2004-06-28 20:11 ` bangerth at dealii dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu dot org @ 2004-06-17 2:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From redi at gcc dot gnu dot org 2004-06-17 02:04 -------
I configured with concept-checks and PCH enabled
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
2004-06-17 2:04 ` [Bug libstdc++/16021] " redi at gcc dot gnu dot org
@ 2004-06-28 20:11 ` bangerth at dealii dot org
2004-06-30 14:41 ` redi at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-06-28 20:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-28 19:52 -------
I would argue that your code is in fact invalid, since you may not
redefine members of namespace std. That being said, we should still
make an attempt to get it working, or at least get the error messages
to reflect what we mean.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
2004-06-17 2:04 ` [Bug libstdc++/16021] " redi at gcc dot gnu dot org
2004-06-28 20:11 ` bangerth at dealii dot org
@ 2004-06-30 14:41 ` redi at gcc dot gnu dot org
2004-06-30 15:22 ` bangerth at dealii dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu dot org @ 2004-06-30 14:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From redi at gcc dot gnu dot org 2004-06-30 14:39 -------
Wolfgang, isn't this a specialisation of std::vector<T>::swap() (where T is a
user-defined type, not a template parameter) and therefore legal?
If it's illegal then there are lots of libstdc++ testsuite files that need fixing,
since my code was adapted from the testsuite and the code works fine in non-debug
mode.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-06-30 14:41 ` redi at gcc dot gnu dot org
@ 2004-06-30 15:22 ` bangerth at dealii dot org
2004-06-30 17:32 ` giovannibajo at libero dot it
` (7 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-06-30 15:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-30 15:07 -------
I think the compiler should accept it, but adding anything to namespace std::
gets you on thin ice.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-06-30 15:22 ` bangerth at dealii dot org
@ 2004-06-30 17:32 ` giovannibajo at libero dot it
2004-06-30 17:36 ` bangerth at dealii dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: giovannibajo at libero dot it @ 2004-06-30 17:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-06-30 17:29 -------
Wolfgang, the standard explicitally says that the only thing you are allowed to
define in namespace std are specializations of standard templates. Everything
else brings you into undefined behaviour, but this very thing is allowed and
should work also in debug mode.
This is just another bug with strong using, I thikn it's a dup of whatever bug
is left around about this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug libstdc++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-06-30 17:32 ` giovannibajo at libero dot it
@ 2004-06-30 17:36 ` bangerth at dealii dot org
2004-06-30 19:33 ` [Bug c++/16021] " bangerth at dealii dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-06-30 17:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-30 17:32 -------
Thanks, Giovanni, for the explanation.
I thought about the strong using thingy as well, but then I was under
the impression that it had been backed out of the compiler. We should
try to come up with a smaller example, though I won't have the time to
do so today.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-06-30 17:36 ` bangerth at dealii dot org
@ 2004-06-30 19:33 ` bangerth at dealii dot org
2004-08-02 18:52 ` mmitchel at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-06-30 19:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-30 17:49 -------
Hm, I _had_ to do it:
-----------------
namespace NS {}
namespace std {
using namespace NS __attribute__ ((strong));
class A{};
}
namespace NS {
template<typename _Tp, typename _A = std::A>
class X {
void swap (X&);
};
}
struct T {};
namespace std {
template<>
void X<T, A>::swap(X<T, A>&) {}
}
-------------------
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc:19: error: `A' was not declared in this scope
x.cc:19: error: template argument 2 is invalid
x.cc:19: error: ISO C++ forbids declaration of `parameter' with no type
x.cc:19: error: no member function `swap' declared in `NS::X<T, std::A>'
x.cc:19: error: invalid function declaration
That's of course bogus: 'A' _is_ declared in this scope, since it's a class
inside namespace std, which we are presently in.
The code is extracted from debug mode libstdc++, in which NS is the namespace
in which the debug version of the containers are declared. If we want user
programs to be able to compile with both debug and non-debug mode, we need
to be able to allow specializations of NS::X members in namespace std, as
shown in the example. Thus, the code should really compile.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|libstdc++ |c++
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-06-30 17:49:04
date| |
Target Milestone|--- |3.4.2
Version|3.5.0 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (6 preceding siblings ...)
2004-06-30 19:33 ` [Bug c++/16021] " bangerth at dealii dot org
@ 2004-08-02 18:52 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-02 18:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-08-02 18:52 -------
Assigned to Jason, as the inventor of "strong using".
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at redhat dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-08-02 18:52 ` mmitchel at gcc dot gnu dot org
@ 2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org
2004-11-01 0:46 ` mmitchel at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 18:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-08-29 18:51 -------
Postponed until GCC 3.4.3.
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.2 |3.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (8 preceding siblings ...)
2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org
@ 2004-11-01 0:46 ` mmitchel at gcc dot gnu dot org
2005-02-12 22:33 ` pinskia at gcc dot gnu dot org
2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
11 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-11-01 0:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-11-01 00:45 -------
Postponed until GCC 3.4.4.
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.3 |3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (9 preceding siblings ...)
2004-11-01 0:46 ` mmitchel at gcc dot gnu dot org
@ 2005-02-12 22:33 ` pinskia at gcc dot gnu dot org
2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
11 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-12 22:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-12 21:00 -------
*** Bug 19550 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
` (10 preceding siblings ...)
2005-02-12 22:33 ` pinskia at gcc dot gnu dot org
@ 2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
11 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:30 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.4 |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2006-01-26 22:29 ` jason at gcc dot gnu dot org
@ 2006-02-28 9:28 ` gdr at gcc dot gnu dot org
4 siblings, 0 replies; 18+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-02-28 9:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #16 from gdr at gcc dot gnu dot org 2006-02-28 09:27 -------
Fixed in 4.2 and up.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|3.4.6 |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2005-11-21 2:12 ` gdr at gcc dot gnu dot org
@ 2006-01-26 22:29 ` jason at gcc dot gnu dot org
2006-02-28 9:28 ` gdr at gcc dot gnu dot org
4 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-01-26 22:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from jason at gcc dot gnu dot org 2006-01-26 22:29 -------
Subject: Bug 16021
Author: jason
Date: Thu Jan 26 22:29:12 2006
New Revision: 110282
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110282
Log:
PR c++/16021
* name-lookup.c (parse_using_directive): Require strong using to
name a nested namespace.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/name-lookup.c
trunk/gcc/testsuite/g++.dg/lookup/strong-using-1.C
trunk/gcc/testsuite/g++.dg/lookup/strong-using-2.C
trunk/gcc/testsuite/g++.dg/lookup/strong-using-3.C
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
2005-11-17 17:18 ` jason at gcc dot gnu dot org
2005-11-17 18:14 ` jason at gcc dot gnu dot org
@ 2005-11-21 2:12 ` gdr at gcc dot gnu dot org
2006-01-26 22:29 ` jason at gcc dot gnu dot org
2006-02-28 9:28 ` gdr at gcc dot gnu dot org
4 siblings, 0 replies; 18+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-21 2:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from gdr at gcc dot gnu dot org 2005-11-21 02:12 -------
(In reply to comment #13)
> It also works if NS is nested within std, as in the example in the GCC
> documentation.
>
So, Jason, do you want to close this as WONTFIX for 3.4.x?
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
Target Milestone|3.4.5 |3.4.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
2005-11-17 17:18 ` jason at gcc dot gnu dot org
@ 2005-11-17 18:14 ` jason at gcc dot gnu dot org
2005-11-21 2:12 ` gdr at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu dot org @ 2005-11-17 18:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jason at gcc dot gnu dot org 2005-11-17 18:14 -------
It also works if NS is nested within std, as in the example in the GCC
documentation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c++/16021] Tests for container swap specialisations FAIL in debug mode
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
@ 2005-11-17 17:18 ` jason at gcc dot gnu dot org
2005-11-17 18:14 ` jason at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu dot org @ 2005-11-17 17:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2005-11-17 17:18 -------
The testcase compiles fine if you add
using namespace std;
within namespace NS. I'm not sure whether or not this should be implied by the
strong using.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2006-02-28 9:27 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-16 12:15 [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode redi at gcc dot gnu dot org
2004-06-17 2:04 ` [Bug libstdc++/16021] " redi at gcc dot gnu dot org
2004-06-28 20:11 ` bangerth at dealii dot org
2004-06-30 14:41 ` redi at gcc dot gnu dot org
2004-06-30 15:22 ` bangerth at dealii dot org
2004-06-30 17:32 ` giovannibajo at libero dot it
2004-06-30 17:36 ` bangerth at dealii dot org
2004-06-30 19:33 ` [Bug c++/16021] " bangerth at dealii dot org
2004-08-02 18:52 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org
2004-11-01 0:46 ` mmitchel at gcc dot gnu dot org
2005-02-12 22:33 ` pinskia at gcc dot gnu dot org
2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
[not found] <bug-16021-5876@http.gcc.gnu.org/bugzilla/>
2005-11-17 17:18 ` jason at gcc dot gnu dot org
2005-11-17 18:14 ` jason at gcc dot gnu dot org
2005-11-21 2:12 ` gdr at gcc dot gnu dot org
2006-01-26 22:29 ` jason at gcc dot gnu dot org
2006-02-28 9:28 ` gdr 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).