public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5543: gcc 2.95.3 does not resolve intricate template
@ 2002-01-30 19:07 rodrigc
  0 siblings, 0 replies; 2+ messages in thread
From: rodrigc @ 2002-01-30 19:07 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, grzesik, nobody

Synopsis: gcc 2.95.3 does not resolve intricate template

State-Changed-From-To: open->analyzed
State-Changed-By: rodrigc
State-Changed-When: Wed Jan 30 19:07:05 2002
State-Changed-Why:
    I think you need the template specialization in order
    to compile your code.  I get the same error with
    gcc 3.0.3 and gcc 3.1.
    
    Compiling with Comeau C++, I get:
    "7397.c", line 35: error: no operator "*" matches these operands
                operand types are: B<A<type<int>>, type<int>>::C * B<A<type<int>>,
                          type<int>>::C
        c = c1() * c2 (); //does not compile, unless operator* is specialized (see above)
                 ^
    
    I'm not a template expert though, so can't say
    for sure.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5543


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

* c++/5543: gcc 2.95.3 does not resolve intricate template
@ 2002-01-30 11:56 grzesik
  0 siblings, 0 replies; 2+ messages in thread
From: grzesik @ 2002-01-30 11:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5543
>Category:       c++
>Synopsis:       gcc 2.95.3 does not resolve intricate template
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 30 11:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Axel Grzesik
>Release:        2.95.3
>Organization:
>Environment:
Linux Kernel 2.4
>Description:
bizarre.cc: In function `int main()':
bizarre.cc:40: no match for `B<A<type<int> >,type<int> >::C * B<A<type<int> >,type<int> >::C'
>How-To-Repeat:
//I'm repeating the source code that is included in my attachment
template <class S> struct type {
  S s;
  type ( S ss = 0 ) : s ( ss ) {}
};

template <class S> type<S> operator* ( type<S> s1, type<S> s2 )
{
  type< S > t ( s1.s*s2.s );
  return t;
}

template <class T> struct A { 
  T d; 
  A() : d( 0 ) {}          
};

template <class R, class T> struct B {
  R* r;
  struct C {
    B& v;
    C ( B& vv ) : v ( vv ) {} 
    operator T() { return v.r->d; }
  };
  B() { r = new R(); }
  C operator() () { return C(*this); }
};

int main () 
{
  B< A<double>, double > b1, b2;
  B< A<type<int> >, type<int> > c1, c2;
  double b; type<int> c;
  b = b1() * b2 (); //works fine
  c = c1() * c2 (); //does not compile, unless operator* is specialized (see above)
  c = static_cast<type<int> > (c1()) * static_cast<type<int> > (c2()); //works fine 
  return 0;
}
>Fix:
//this is also included in my attachment
//include this specialization to make error disappear! (Work-around, as you call it ....)
type<int> operator* ( type<int> s1, type<int> s2 )
{
  type<int> t ( s1.s*s2.s );
  return t;
}
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bizarre.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bizarre.cc"

dGVtcGxhdGUgPGNsYXNzIFM+IHN0cnVjdCB0eXBlIHsKICBTIHM7CiAgdHlwZSAoIFMgc3MgPSAw
ICkgOiBzICggc3MgKSB7fQp9OwoKdGVtcGxhdGUgPGNsYXNzIFM+IHR5cGU8Uz4gb3BlcmF0b3Iq
ICggdHlwZTxTPiBzMSwgdHlwZTxTPiBzMiApCnsKICB0eXBlPCBTID4gdCAoIHMxLnMqczIucyAp
OwogIHJldHVybiB0Owp9CgovL2luY2x1ZGUgdGhpcyBzcGVjaWFsaXphdGlvbiB0byBtYWtlIGVy
cm9yIGRpc2FwcGVhciEgKFdvcmstYXJvdW5kLCBhcyB5b3UgY2FsbCBpdCAuLi4uKQovL3R5cGU8
aW50PiBvcGVyYXRvciogKCB0eXBlPGludD4gczEsIHR5cGU8aW50PiBzMiApCi8vewovLyAgdHlw
ZTxpbnQ+IHQgKCBzMS5zKnMyLnMgKTsKLy8gIHJldHVybiB0OwovL30KCnRl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CiovCgo=


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

end of thread, other threads:[~2002-01-31  3:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-30 19:07 c++/5543: gcc 2.95.3 does not resolve intricate template rodrigc
  -- strict thread matches above, loose matches on Subject: below --
2002-01-30 11:56 grzesik

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