Bug 14926 - [3.4/4.0 regression] forward declarations and strong using
Summary: [3.4/4.0 regression] forward declarations and strong using
Status: RESOLVED DUPLICATE of bug 14370
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-12 17:47 UTC by Vasili Burdo
Modified: 2004-10-30 21:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-04-12 17:57:49


Attachments
Test case #1 (22.69 KB, application/octet-stream)
2004-04-12 17:48 UTC, Vasili Burdo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vasili Burdo 2004-04-12 17:47:19 UTC
the code:

namespace std 
{
	template<class,class> class vector;//forward declaration
}

#include <vector>

int main()
{
	std::vector<int> v;
	return 0;
}

causes following compile-time error:

bug.cxx:2: error:   first declared as `template<class, class> struct 
std::vector' here
d:/tools/gcc/include/c++/3.4.0/bits/stl_vector.h:141: error:   also declared as 
`template<class _Tp, class _Alloc> class __gnu_norm::vector' here
bug.cxx:9: error: use of `vector' is ambiguous
Comment 1 Vasili Burdo 2004-04-12 17:48:13 UTC
Created attachment 6078 [details]
Test case #1
Comment 2 Vasili Burdo 2004-04-12 17:53:40 UTC
I believe this bug is related to __attribute__((strong)) introduced in 3.4.0 
and PR #13659
Comment 3 Wolfgang Bangerth 2004-04-12 17:57:48 UTC
Confirmed, an interesting side-effect of the strong-using extension in 
gcc. I guess Jason would be the right person? 
 
In any case, this is a regression in 3.4 and mainline over all previous 
versions. 
 
W. 
Comment 4 Paolo Carlini 2004-04-12 18:03:02 UTC
Isn't this a duplicate of libstdc++/14370 (INVALID) ??
Comment 5 Gabriel Dos Reis 2004-04-12 18:37:53 UTC
Subject: Re:  New: libstdc++ rejects forward declarations.

"vassili_bourdo at softhome dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| the code:
| 
| namespace std 
| {
| 	template<class,class> class vector;//forward declaration

This is invoking undefined behaviour.
Comment 6 Gabriel Dos Reis 2004-04-12 18:42:28 UTC
Subject: Re:  libstdc++ rejects forward declarations.

"vassili_bourdo at softhome dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| I believe this bug is related to __attribute__((strong)) introduced in 3.4.0 
| and PR #13659

It is not a bug, it is a feature.
It never has been valid for users to forward declare primary templates
in std::.

-- Gaby
Comment 7 Gabriel Dos Reis 2004-04-12 18:43:30 UTC
Subject: Re:  [3.4/3.5 regression] forward declarations and strong using

"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| Isn't this a duplicate of libstdc++/14370 (INVALID) ??

It is.  (It is good to know someone remembers the PR ids :-))

Comment 8 Wolfgang Bangerth 2004-04-12 19:03:20 UTC
Alright then. I thought that this is something we should think about 
for the C++ side (not the libstdc++ side) regarding the semantics we 
give the strong using extension. However, you are right that we do 
not have to worry about this: as far as the library is concerned, the 
user can't rely on forward declaring stuff anyway (we are, IIRC, allowed 
to introduce additional template default parameters for example), and if 
this happens in user space with a user using "strong using", we can simply 
tell him to forward declare in the right namespace. 
 
W. 

*** This bug has been marked as a duplicate of 14370 ***
Comment 9 Gabriel Dos Reis 2004-04-12 19:48:23 UTC
Subject: Re:  [3.4/3.5 regression] forward declarations and strong using

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| ------- Additional Comments From bangerth at dealii dot org  2004-04-12 19:03 -------
| Alright then. I thought that this is something we should think about 
| for the C++ side (not the libstdc++ side) regarding the semantics we 
| give the strong using extension. However, you are right that we do 
| not have to worry about this: as far as the library is concerned, the 
| user can't rely on forward declaring stuff anyway (we are, IIRC, allowed 
| to introduce additional template default parameters for example), and if 

Err, we're not allowed to introduce additional default template
parameters (contrary to what the latitude parameters for non virtual
member functions) 

| this happens in user space with a user using "strong using", we can simply 
| tell him to forward declare in the right namespace. 

Yes, "strong using" is for the super user :-)

-- Gaby
Comment 10 Wolfgang Bangerth 2004-04-12 20:00:25 UTC
I was under the impression that an implementation was allowed to declare 
(for example) its vector class as 
  template <typename T, typename Allocator = alloc<something>, 
            typename additional_parameter=something > 
  class vector {...}; 
and that this was the reason to make forward declarations of classes in 
namespace std:: undefined. I may be wrong, though. It doesn't also matter 
here. 
 
W. 
Comment 11 llewelly 2004-04-12 21:52:50 UTC
Subject: Re:  [3.4/3.5 regression] forward declarations and strong using

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

> ------- Additional Comments From bangerth at dealii dot org  2004-04-12 20:00 -------
> I was under the impression that an implementation was allowed to declare 
> (for example) its vector class as 
>   template <typename T, typename Allocator = alloc<something>, 
>             typename additional_parameter=something > 
>   class vector {...}; 
> and that this was the reason to make forward declarations of classes in 
> namespace std:: undefined. I may be wrong, though. It doesn't also matter 
> here. 

http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-closed.html#94
explains why additional template parameters are not allowed.
Comment 12 Wolfgang Bangerth 2004-04-12 22:11:30 UTC
Ah, thanks for the pointer. I am around too long, so the original discussion 
was still sticking in my head as there was a time when things like  
additional template parameters could happen to you... 
 
W.