overloaded templated ostream-operator: gcc can't find the right one.

Johan Myhre Andersen jma@cpk.auc.dk
Wed Mar 1 12:46:00 GMT 2000


Sorry to bug you before.
Here comes the right bug-report. I had changed the example before to
make it work. Here is the original .cc which cause the problem.
When pair in main is not const, it does not work. gcc fails to find
operator<< defined for const pair. Instead it tries to use operator<<
that I definded for template T, which is supposed to be a container.

--Johan

Johan Myhre Andersen wrote:
> 
> Hello,
> 
> I think I found a bug. To illustrate it I made the attached example.
> With more than one templated overloaded ostream operator, gcc has
> trouble finding the right one. It fails to convert a non-const argument
> to a const arg. when the function is called. Instead it tries to match
> the call to the wrong function.
> I run solaris2.5.1 on a Sun Sparc.
> 
> Command-line for compilation/linking:
> /pack/gcc-2.95.2/bin/g++ -v --save-temps -g template_ostream_test.cc -o
> template_ostream_test.exe -R/pack/gcc-2.95.2/lib &>
> template_ostream_test.make.log
> 
> attached is a .tar.gz with
> template_ostream_test.cc
> template_ostream_test.make.log
> template_ostream_test.ii
no: > template_ostream_test.o
> template_ostream_test.s
> 
> Enjoy! :)
> 
> Regards,
> Johan Andersen,
> Aalborg University
> 
>   ------------------------------------------------------------------------
>                                    Name: template_ostream_test.tar.gz
>    template_ostream_test.tar.gz    Type: Unix Tape Archive (application/x-tar)
>                                Encoding: base64
template_ostream_test.tar.gz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: template_ostream_test.tar.gz
Type: application/x-gzip
Size: 41406 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000301/c0634613/attachment.bin>


More information about the Gcc-bugs mailing list