public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17057] New: problems disambiguating std::allocator::rebind
@ 2004-08-17  4:00 bkoz at gcc dot gnu dot org
  2004-08-17  4:01 ` [Bug c++/17057] " bkoz at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-08-17  4:00 UTC (permalink / raw)
  To: gcc-bugs

The attached pre-process file will not compile on linux with today's gcc.

gcc version 3.5.0 20040816 (experimental)

However, EDG FE's don't have a problem with it. Indeed, it looks right to me,
but perhaps I miss something.

I get:

In file included from
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/i686-pc-linux-gnu/bits/c++allocator.h:35,
                 from
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/bits/allocator.h:53,
                 from
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/memory:56,
                 from ext/mt_allocator.cc:3:
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h:277:
error: non-template `_M_rebind' used as template
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h:277:
note: use `_PoolTp1::template _M_rebind' to indicate that it is a template
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h:277:
error: type `_PoolTp1' is not derived from type `__gnu_cxx::__mt_alloc<_Tp,
_PoolTp>::rebind<_Tp1, _PoolTp1>'
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h:278:
error: `rebind_type' was not declared in this scope
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h:278:
error: template argument 2 is invalid
ext/mt_allocator.cc: In function `void test04()':
ext/mt_allocator.cc:180: error: non-template `rebind' used as template
ext/mt_allocator.cc:180: note: use `test04()::allocator_type::template rebind'
to indicate that it is a template
ext/mt_allocator.cc:180: error: too few template-parameter-lists
ext/mt_allocator.cc:182: error: `rebind_type' was not declared in this scope
ext/mt_allocator.cc:182: error: expected `;' before "a2"
ext/mt_allocator.cc:183: error: `a2' was not declared in this scope
ext/mt_allocator.cc:185: error: `rebind_type' is not a class or namespace
ext/mt_allocator.cc:196: error: `rebind_type' is not a class or namespace
ext/mt_allocator.cc:196: error: `pointer' does not name a type
ext/mt_allocator.cc:204: error: `p2' was not declared in this scope


The suggestion that g++ throws out there turns out to not be helpful.

-benjamin

-- 
           Summary: problems disambiguating std::allocator::rebind
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
@ 2004-08-17  4:01 ` bkoz at gcc dot gnu dot org
  2004-08-17  4:04 ` bkoz at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-08-17  4:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at gcc dot gnu dot org  2004-08-17 04:01 -------
Created an attachment (id=6946)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6946&action=view)
preprocessed source


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
  2004-08-17  4:01 ` [Bug c++/17057] " bkoz at gcc dot gnu dot org
@ 2004-08-17  4:04 ` bkoz at gcc dot gnu dot org
  2004-08-17  4:13 ` bkoz at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-08-17  4:04 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at codesourcery dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
  2004-08-17  4:01 ` [Bug c++/17057] " bkoz at gcc dot gnu dot org
  2004-08-17  4:04 ` bkoz at gcc dot gnu dot org
@ 2004-08-17  4:13 ` bkoz at gcc dot gnu dot org
  2004-08-17  4:57 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-08-17  4:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at gcc dot gnu dot org  2004-08-17 04:13 -------

Ditto for gcc-3_4-branch.20040815, same message.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-08-17  4:13 ` bkoz at gcc dot gnu dot org
@ 2004-08-17  4:57 ` pinskia at gcc dot gnu dot org
  2004-08-17  5:01 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17  4:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 04:57 -------
It looks like you missed something obvious (and ICC did also):

template<typename _Tp, typename _Cp>

  typedef _Tp value_type;
  typedef _Cp policy_type;
  typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
  typedef allocator_type::rebind<value2_type>::other rebind_type;

allocator_type is dependent so how can any compiler know that allocator_type::rebind is a template 
and that allocator_type::rebind<value2_type>::other names a typename.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-08-17  4:57 ` pinskia at gcc dot gnu dot org
@ 2004-08-17  5:01 ` pinskia at gcc dot gnu dot org
  2004-08-17  5:52 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17  5:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 05:01 -------
I should note the same thing about rebind_type::policy_type too.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-08-17  5:01 ` pinskia at gcc dot gnu dot org
@ 2004-08-17  5:52 ` mmitchel at gcc dot gnu dot org
  2004-08-17 13:38 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-17  5:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-17 05:52 -------
I agree with Andrew.  Note that EDG -- without the "-A" flag -- will try to look
up names in dependent contexts (in violation of the standard) in order to
support legacy code.  So, when comparing with EDG, you should always use "-A". 
(I'm not sure how icc spells that flag.)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-08-17  5:52 ` mmitchel at gcc dot gnu dot org
@ 2004-08-17 13:38 ` bangerth at dealii dot org
  2004-08-17 16:10 ` bkoz at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bangerth at dealii dot org @ 2004-08-17 13:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-17 13:38 -------
icc's flag is "-Xc -ansi" (that may actually be the same flag under two separate names, 
but the documentation isn't quite clear to me). 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-08-17 13:38 ` bangerth at dealii dot org
@ 2004-08-17 16:10 ` bkoz at gcc dot gnu dot org
  2004-08-17 16:22 ` mark at codesourcery dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-08-17 16:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at gcc dot gnu dot org  2004-08-17 16:10 -------

With all due respect, I think the preliminary analysis is not absolutely correct.

First of all, it makes no difference what the EDG/icc flags are: both chug
through  this code without error or warning. I'm using Version 8.1  Beta  Build
20040602Z with gnu headers, but I'm not quite sure this really matters.

Second, Andrew's summation is not what the code details. My apology: 
Perhaps I attached the wrong pre-processed code the first time. I've tried
again, see mt_allocator.ii.

To recap:

  template<typename _Tp, typename _PoolTp>
    class __mt_alloc : public _PoolTp
    {
    public:

      template<typename _Tp1, typename _PoolTp1 = _PoolTp>
        struct rebind
        { 
#if 1
          // ok with edg
	  typedef _PoolTp1::_M_rebind<_Tp1>::other pool_type;
#else
          // as g++ suggests but cannot compile
          typedef _PoolTp1::template _M_rebind<_Tp1>::other pool_type;
#endif
	  typedef __mt_alloc<_Tp1, pool_type> other; 
	};
    };

None of these work with g++. If I just keep on adding junk, say

	  typedef typename _PoolTp1::template _M_rebind<_Tp1>::other pool_type;


this compiles with both g++ and EDG. Syntax only a mother could love (could this
really get any uglier?), but hey, it works.

-benjamin

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-08-17 16:10 ` bkoz at gcc dot gnu dot org
@ 2004-08-17 16:22 ` mark at codesourcery dot com
  2004-08-17 16:32 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mark at codesourcery dot com @ 2004-08-17 16:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2004-08-17 16:22 -------
Subject: Re:  problems disambiguating std::allocator::rebind

bkoz at gcc dot gnu dot org wrote:

>------- Additional Comments From bkoz at gcc dot gnu dot org  2004-08-17 16:10 -------
>
>With all due respect, I think the preliminary analysis is not absolutely correct.
>
>First of all, it makes no difference what the EDG/icc flags are: both chug
>through  this code without error or warning. I'm using Version 8.1  Beta  Build
>20040602Z with gnu headers, but I'm not quite sure this really matters.
>
>Second, Andrew's summation is not what the code details. My apology: 
>Perhaps I attached the wrong pre-processed code the first time. I've tried
>again, see mt_allocator.ii.
>
>To recap:
>
>  template<typename _Tp, typename _PoolTp>
>    class __mt_alloc : public _PoolTp
>    {
>    public:
>
>      template<typename _Tp1, typename _PoolTp1 = _PoolTp>
>        struct rebind
>        { 
>#if 1
>          // ok with edg
>	  typedef _PoolTp1::_M_rebind<_Tp1>::other pool_type;
>#else
>          // as g++ suggests but cannot compile
>          typedef _PoolTp1::template _M_rebind<_Tp1>::other pool_type;
>#endif
>	  typedef __mt_alloc<_Tp1, pool_type> other; 
>	};
>    };
>
>None of these work with g++. If I just keep on adding junk, say
>
>	  typedef typename _PoolTp1::template _M_rebind<_Tp1>::other pool_type;
>
>
>this compiles with both g++ and EDG. Syntax only a mother could love (could this
>really get any uglier?), but hey, it works.
>
The last version is definitely valid.

I do not believe the case in "#if 1" is valid. 

There are DRs in the works that might make it valid, though; there has 
been some suggestion that in "type contexts" (like the first operand to 
"typedef") "typename" should be assumed.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2004-08-17 16:22 ` mark at codesourcery dot com
@ 2004-08-17 16:32 ` pinskia at gcc dot gnu dot org
  2004-08-17 16:40 ` bkoz at redhat dot com
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17 16:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 16:32 -------
I should note my previous analysis comes after fixing the what I thought was a simple typos but what 
you complaining about as ICC 8.0 rejects the code in strict mode (-Xc -ansi):

Note that turning on strict mode (-Xc -ansi), ICC 8.0 rejects the code:
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h(278): error: name 
followed by "::" must be a class or namespace name
     typedef _PoolTp1::_M_rebind<_Tp1>::other pool_type;
                       ^

compilation aborted for pr17057.ii (code 2)

After adding the template, ICC 8.0 still rejects it:
/mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/ext/mt_allocator.h(278): error: nontype 
"_PoolTp1::_M_rebind<_Tp1>::other" is not a type name
     typedef _PoolTp1::template _M_rebind<_Tp1>::other pool_type;
             ^

compilation aborted for pr17057.ii (code 2)

and adding the typename fixes the problem which is the same code which you came up with to fix for 
GCC so it looks again you did not turn on strict mode in EDG or ICC.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2004-08-17 16:32 ` pinskia at gcc dot gnu dot org
@ 2004-08-17 16:40 ` bkoz at redhat dot com
  2004-08-17 16:41 ` bkoz at redhat dot com
  2004-08-18 22:19 ` gdr at integrable-solutions dot net
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at redhat dot com @ 2004-08-17 16:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at redhat dot com  2004-08-17 16:40 -------
Subject: Re:  problems disambiguating std::allocator::rebind


>The last version is definitely valid.

Thanks! This is what I had assumed. That's what I am using now.

>I do not believe the case in "#if 1" is valid. 

Ok. Be forwarned that most references on the web, as well as C++
textbooks, assume this approach will work. At leat there is a bugzilla
thread now, so google searches will find this.

>There are DRs in the works that might make it valid, though; there has 
>been some suggestion that in "type contexts" (like the first operand to 
>"typedef") "typename" should be assumed.

Here's hoping! I think the unambiguously correct syntax completely blows!

thanks again,
benjamin


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2004-08-17 16:40 ` bkoz at redhat dot com
@ 2004-08-17 16:41 ` bkoz at redhat dot com
  2004-08-18 22:19 ` gdr at integrable-solutions dot net
  12 siblings, 0 replies; 14+ messages in thread
From: bkoz at redhat dot com @ 2004-08-17 16:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bkoz at redhat dot com  2004-08-17 16:41 -------
Subject: Re:  problems disambiguating std::allocator::rebind


>ICC 8.0 rejects the code in strict mode (-Xc -ansi):

Hmm. Well, I am using a different EDG FE than you (see my last message),
and perhaps different sources (see my last attachment) even though I
used these flags.

Anyway, I think this issue is now resolved to my satisfaction. Thanks!

-benjamin


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/17057] problems disambiguating std::allocator::rebind
  2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2004-08-17 16:41 ` bkoz at redhat dot com
@ 2004-08-18 22:19 ` gdr at integrable-solutions dot net
  12 siblings, 0 replies; 14+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-18 22:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-18 22:18 -------
Subject: Re:  problems disambiguating std::allocator::rebind

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

| To recap:
| 
|   template<typename _Tp, typename _PoolTp>
|     class __mt_alloc : public _PoolTp
|     {
|     public:
| 
|       template<typename _Tp1, typename _PoolTp1 = _PoolTp>
|         struct rebind
|         { 
| #if 1
|           // ok with edg
| 	  typedef _PoolTp1::_M_rebind<_Tp1>::other pool_type;

This is wrong.  Missing infamous "::template" and "typename".

| #else
|           // as g++ suggests but cannot compile
|           typedef _PoolTp1::template _M_rebind<_Tp1>::other pool_type;

This is wron. Missing infamous "typename".

| #endif
| 	  typedef __mt_alloc<_Tp1, pool_type> other; 
| 	};
|     };
| 
| None of these work with g++. If I just keep on adding junk, say
| 
| 	  typedef typename _PoolTp1::template _M_rebind<_Tp1>::other pool_type;

This junk is correct standard way to write it


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17057


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-08-18 22:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-17  4:00 [Bug c++/17057] New: problems disambiguating std::allocator::rebind bkoz at gcc dot gnu dot org
2004-08-17  4:01 ` [Bug c++/17057] " bkoz at gcc dot gnu dot org
2004-08-17  4:04 ` bkoz at gcc dot gnu dot org
2004-08-17  4:13 ` bkoz at gcc dot gnu dot org
2004-08-17  4:57 ` pinskia at gcc dot gnu dot org
2004-08-17  5:01 ` pinskia at gcc dot gnu dot org
2004-08-17  5:52 ` mmitchel at gcc dot gnu dot org
2004-08-17 13:38 ` bangerth at dealii dot org
2004-08-17 16:10 ` bkoz at gcc dot gnu dot org
2004-08-17 16:22 ` mark at codesourcery dot com
2004-08-17 16:32 ` pinskia at gcc dot gnu dot org
2004-08-17 16:40 ` bkoz at redhat dot com
2004-08-17 16:41 ` bkoz at redhat dot com
2004-08-18 22:19 ` gdr at integrable-solutions dot net

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).