public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15538] New: Fails to recognize type name
@ 2004-05-19 23:52 igodard at pacbell dot net
  2004-05-19 23:54 ` [Bug c++/15538] " igodard at pacbell dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 23:52 UTC (permalink / raw)
  To: gcc-bugs

This is the "curiously recursive template" pattern, where the derived class is a template argument to its own base class, but modified by having the argument being the template for the derived class rather than a particular derived class. When the argument is a plain class (including template instance) then the base class can refer to the public type members of the argument. However in this case it doesn't find a public type member of an instantiation of the template argument.

The standard in this area is beyond me, so maybe it really isn't supposed to recognize the member type for some reason. But if so, please change the error message from:
/home/ivan/ootbc/common/include/allocator.hh:36: error: no type named `const_pointer' in `class StdAllocator<int>'

to something that indicates what is actually wrong, because in fact there is a type with that name and it can be referenced successfully from outside the StdAllocator<int>.

-- 
           Summary: Fails to recognize type name
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/15538] Fails to recognize type name
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
@ 2004-05-19 23:54 ` igodard at pacbell dot net
  2004-05-19 23:55 ` igodard at pacbell dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 23:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 09:56 -------
Created an attachment (id=6339)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6339&action=view)
Compiler output (-v -save-temps)


-- 


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


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

* [Bug c++/15538] Fails to recognize type name
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
  2004-05-19 23:54 ` [Bug c++/15538] " igodard at pacbell dot net
@ 2004-05-19 23:55 ` igodard at pacbell dot net
  2004-05-20  0:07 ` igodard at pacbell dot net
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 23:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 09:57 -------
Created an attachment (id=6340)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6340&action=view)
Source code (-save-temps)


-- 


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


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

* [Bug c++/15538] Fails to recognize type name
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
  2004-05-19 23:54 ` [Bug c++/15538] " igodard at pacbell dot net
  2004-05-19 23:55 ` igodard at pacbell dot net
@ 2004-05-20  0:07 ` igodard at pacbell dot net
  2004-05-20  0:34 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-20  0:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 10:13 -------
Here's a simpler case:
template<typename D>
class A {public: typedef int B; typename D::Q r;};
template<typename T, template<typename>class C> class E
    {public: typedef int F; typename C<T>::Q q;};

template<typename G>class H : public A<H<G> >, public E<G, H> {
public:
typedef G* Q;

};

H<bool> h;
H<bool>::Q q;
int main() {
    return 0;
    }

Note that I can declare "q" with the same type "G<bool>::Q" that the compiler claims doesn't exist.

Very confusing message even if my usage is invalid.

Ivan

-- 


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


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

* [Bug c++/15538] Fails to recognize type name
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2004-05-20  0:07 ` igodard at pacbell dot net
@ 2004-05-20  0:34 ` pinskia at gcc dot gnu dot org
  2004-05-20 15:10 ` [Bug c++/15538] Message does not indicate that we are trying to look into an incomplete type bangerth at dealii dot org
  2004-11-04 14:27 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-20  0:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-19 11:03 -------
This is just a diagnostic problem see what ICC 6.0 says:
pr15538.cc
pr15538.cc(2): error: incomplete type is not allowed
  class A {public: typedef int B; typename D::Q r;};
                                           ^
          detected during:
            instantiation of class "A<D> [with D=H<bool>]" at line 6
            instantiation of class "H<G> [with G=bool]" at line 12

pr15538.cc(4): error: incomplete type is not allowed
      {public: typedef int F; typename C<T>::Q q;};
                                       ^
          detected during:
            instantiation of class "E<T, C> [with T=bool, C=H]" at line 6
            instantiation of class "H<G> [with G=bool]" at line 12

compilation aborted for pr15538.cc (code 2)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-19 11:03:03
               date|                            |


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


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

* [Bug c++/15538] Message does not indicate that we are trying to look into an incomplete type
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2004-05-20  0:34 ` pinskia at gcc dot gnu dot org
@ 2004-05-20 15:10 ` bangerth at dealii dot org
  2004-11-04 14:27 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-05-20 15:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-05-19 14:07 -------
The problem is actually simpler: 
--------------- 
template <typename D> 
struct A { typename D::Q r;}; 
 
template<typename G> 
struct H : A<H<G> > { typedef G* Q; }; 
 
H<bool> h; 
--------------- 
While you can pass the incomplete type H<G> as a template argument to 
the base class, you can't look into it from the base class (precisely 
because it is incomplete at the time). 
 
We get this here: 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc: In instantiation of `A<H<bool> >': 
x.cc:5:   instantiated from `H<bool>' 
x.cc:7:   instantiated from here 
x.cc:2: error: no type named `Q' in `struct H<bool>' 
 
This is indeed not very helpful, since there _is_ a type Q in H<bool>. 
While the code is invalid, we could do a better job with the diagnostic. 
Here is, for example, what we get from icc: 
 
g/x> icc -Xc -ansi -c x.cc 
x.cc(2): error: incomplete type is not allowed 
  struct A { typename D::Q r;}; 
                      ^ 
          detected during: 
            instantiation of class "A<D> [with D=H<bool>]" at line 5 
            instantiation of class "H<G> [with G=bool]" at line 7 
 
compilation aborted for x.cc (code 2) 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |2.95.3 3.3.1 3.0.4 3.4.0
                   |                            |3.5.0
            Summary|Fails to recognize type name|Message does not indicate
                   |                            |that we are trying to look
                   |                            |into an incomplete type


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


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

* [Bug c++/15538] Message does not indicate that we are trying to look into an incomplete type
  2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2004-05-20 15:10 ` [Bug c++/15538] Message does not indicate that we are trying to look into an incomplete type bangerth at dealii dot org
@ 2004-11-04 14:27 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-04 14:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-04 14:27 -------
*** Bug 18296 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at tat dot physik
                   |                            |dot uni-tuebingen dot de


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


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

end of thread, other threads:[~2004-11-04 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 23:52 [Bug c++/15538] New: Fails to recognize type name igodard at pacbell dot net
2004-05-19 23:54 ` [Bug c++/15538] " igodard at pacbell dot net
2004-05-19 23:55 ` igodard at pacbell dot net
2004-05-20  0:07 ` igodard at pacbell dot net
2004-05-20  0:34 ` pinskia at gcc dot gnu dot org
2004-05-20 15:10 ` [Bug c++/15538] Message does not indicate that we are trying to look into an incomplete type bangerth at dealii dot org
2004-11-04 14:27 ` pinskia 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).